Main Menu

Copy Files from Multiple Sub-folders to a Single Folder

Complete text: https://www.winhelponline.com/blog/move-copy-files-multiple-sub-folders-single-folder/

Using Command-line

Scenario: Let’s copy all files from the d:\vacation snaps\2016 folder and sub-folders to the d:\all snaps folder recursively.

  1. Open a Command Prompt window.
  2. Run the following commands one by one and press ENTER after each line:
md "d:\all snaps"
cd /d "d:\vacation snaps\2016"
for /r %d in (*) do copy "%d" "d:\all snaps\"

This recursively copies all files in the d:\vacation snaps\2016\ folder to the d:\all snaps\ folder. To move the files, replace copy with move

If a file of the same name exists in the destination, you’ll be asked if you want to overwrite or skip the file.

Note: It’s always safe to include the trailing backslash (\) after the destination folder path, as in the above example. Because, without the trailing slash, if the destination path is missing and you run the command, then the files in the folder and subfolders are copied and combined into one single file named all snaps to D:\ drive.



« (Previous News)



Comments are Closed