How to copy files using Windows Batch


I have a directory with several subdirectories with files.
How can I copy all files in the subdirectories to a new location?

Edit: I do not want to copy the directories, just the files…

As this is still on XP, I chose the below solution:

 for /D %S IN ("src\*.*") DO  @COPY "%S\" "dest\"


Best Answer

Ok. With your edit that says you don't want the directory structure, i think you're going to want to use something like this:

for /F "usebackq" %s IN (`DIR /B /S /A-D SrcDir`) DO @(
    XCOPY %s DestDir\%~nxs