copy all files recursively into a single folder (without recreating folders)
Asked Answered
H

1

7

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

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

to

E:\MYFOLDER\

I tried with xcopy but

  • I don't know how to tell "just recurse subfolders of D:\TEMP and not subsubfolders, subsubsubfolders, etc."

  • When using xcopy, folders are created in the destination (in order to replicate source's folder tree), I don't want this : files should be copied in just 1 single folder.

Hutch answered 4/3, 2013 at 19:31 Comment(1)
Check this method, does not require any batch files or learning any DOS commands- pcworld.com/article/2105149/…Chem
E
13

for command is your friend. Read help for and then try this in the command prompt

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

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

thus,

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

will copy all your mp3 to the destination folder.

Earldom answered 4/3, 2013 at 19:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.