I am having a hard time describing the problem and I can't find the solution anywhere so here is an example
SourceFolder\ProjectA\Legal\ContractA.txt
SourceFolder\ProjectB\Legal\ContractB.txt
SourceFolder\ProjectC\Legal\ContractC.txt
SourceFolder\ProjectD\Legal\ContractD.txt
etc..
I need to copy the contractletter.txt file from hundreds of these Projectletter folders to a single location such as this:
DestinationFolder\ContractA.txt
DestinationFolder\ContractB.txt
DestinationFolder\ContractC.txt
DestinationFolder\ContractD.txt
etc..
Is there a PowerShell command that will do it?
gci SourceFolder\Contract* -rec | % {copy-item $_ -destination "DestinationFolder\$($_.name)"}
might do but you would overwrite identical filenames-whatif
just before the}
to do a dry run.