computing
  • 12

Solved Copy Multiple Files In Multiple Folders To One Folder

  • 12

I want to copy files from multiple directories without creating the directory tree. XCOPY /S gets all the files I need, but creates the tree as well. I have more than 500 subdirectories and every folder contains files and other subdirectories. I want to copy all of the files from every subdirectory in main folder: “d:\temp1” into a new folder named d:\temp2 without creating the directory tree. Is there a way to do this without having to create a batch file containing a copy command for every folder?

Share

1 Answer

  1. i have other problem in this case, i have Space in folder’s name and files’ name so these files have not been copied. what can i do?

    Ensure you are including the quotes surrounding the “A” variable and destination folder:

    DO COPY /Y "%~A" "d:\temp2"
    

    and/or

    DO COPY /Y "%%~A" "d:\temp2"
    

    The testing I have done correctly accounts for embedded spaces in both folders and file names.

    When your only tool is a hammer, every problem looks like a nail.

    • 0