Copy file with relative path


I would like to copy all files of a certain type from a certain sub-directory with their relative path from that sub-directory to another directory with the relative path intact. e.g.:

Source sub-dir:

Source files:

Target dir:

Desired result:

So far I’ve come up with:

However, this “everything is an object” à la PowerShell is beating me down (at least that’s what I suspect). I.e. the files gets copied, but without their relative path.

Anyone who could enlighten me a bit?


Don’t bother with PowerShell cmdlets for this, simply use robocopy:


Copy file with relative path by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply