I need to copy the following subset of folders from $sourceDir
to $targetDir
:
abc0001
abc0643
abc0456
...
The number of folders is unknown, but they all match a pattern abc0*
.
Is there an elegant solution to expand abc0*
to the actual list of folders and then copy them? I tried this:
dir "$sourceDir\abc0*" -Recurse | copy -Destination $targetDir -WhatIf
But it does not preserve the path, so all files end up in the root of $targetDir
.