Copy all files recursively to one folder (without creating folders)

With the package (.bat), I want to copy all mp3 files that are in 1 subdirectory D: \ TEMP

D:\TEMP\\(anyfolder)\\(anyfile.mp3) 

to

 E:\MYFOLDER\ 

I tried xcopy but

  • I don’t know how to say "just recursive subfolders of D: \ TEMP, not sub-items, sub-sub-folders, etc."

  • When using xcopy, folders are created at the destination (for replicating the source folder tree), I do not want this: files should be copied to only one folder.

Thanks in advance!

+4
source share
1 answer

for team is your friend. Read help for , and then try on the command line

 for /d %a in (*) do @echo %a 

as you can see, it follows all subfolders in the current directory.

in this way,

 for /d %a in (*) do @copy %a\*.mp3 e:\myfolder 

will copy all your mp3s to the destination folder.

+9
source

All Articles