Home > Net >  How to copy one folder into multiple folders in windows
How to copy one folder into multiple folders in windows

Time:10-21

This is the issue. I have a folder named Covers which is in another folder named Folder A. I have to copy the Covers folder from Folder A to all the sub-folders of another folder named Folder B. There are hundreds of sub-folders in Folder B. How can I do it through command line in windows or even power-shell.

Here is the folder structure:

Folder A Folder B
Covers Sub-Folder 1
Sub-Folder 2
Sub-Folder 3
Sub-Folder 4

The path of the FolderA is D:\AJ\Desktop\FolderA and the path of FolderB is D:\AJ\Desktop\FolderB.

I am trying to copy Covers folder from FolderA to all the sub-folders of FolderB.

CodePudding user response:

This should do it. Use for /? to see the help for the command. /d means wildcards match directories, so it loops through the folders under FolderB and copies the files. xcopy /? will show that /sei will assume the destiniation is a directory and copy subdirectories including empty ones, to make sure everything under Covers gets copied. Use the cd command to start in the initial directory containing the folders:

cd /d d:\aj\desktop
for /d %i in (FolderB\*) do @xcopy "FolderA\Covers" "%i\Covers" /sei
  • Related