Similar to How can I copy file recursively ignoring destination directory structure? but in cmd
.
I'd like to copy all files recursively, but in the destination folder I'd like to squash the directory structure. I first looked at xcopy
, but it does not allow the option to squash the structure (that I can see).
I then looked at for
, but I cannot get it to work when there are spaces in the directory structure. For example:
for /F %f in ('dir /b/s/A-D D:\Libs') do @copy "%f" D:\Bin /Y >NUL
This does not copy any files that reside in a path with spaces. This seems to be due to the fact that for
splits on spaces as well as carriage return characters.
If there is a solution that works in MSBuild, I would accept that too.