Search code examples
command-linecommand-promptdosxcopy

Copy Files From Folders and SubFolders Automatically


How would I go about copying all *.mp3 files from all folders and subfolder to another folder? I would also want this to automatically overwrite any existing file with the same name without being prompted for comfirmation. I don't want to copy the folder structure. I just want to dump all the *.mp3 files into one folder.

Would I use something like xcopy /y *.mp3 g:\MyOldFolder g:\MyNewFolder ?


Solution

  • Test this batch file - make sure that d:\target exists already.

    @echo off
    for /r "c:\base\folder" %%a in (*.mp3) do copy /y "%%a" "d:\target"
    

    For use at the cmd prompt reduce the %% in each spot to a single %