I have to make a script to copy a folder and it's subfolders from one directory into another directory which has hundreds of folders with different name.
The folder structure is similar to below:
Source (Directory M:)
Folder1
--------Subfolder1
--------Subfolder2
--------Subfolder3
Destination (Directory O:)
Folder A
--------SubfolderA
Folder B
--------SubfolderA
Folder C
--------SubfolderA
...
Folder xxx
--------SubfolderA
So far I made it up to this stage but can't get it working.
First I run this piece of code to get the list of folders in the destination directory and export it to a text file
dir /b /ad > c:\temp\folder-list.txt
Now I need to tell the script to copy the folder/subfolders from source to destination but I can't get it working.
FOR %%i in (c:\temp\folder-list.txt) DO xcopy /t /e M:\Folder1 %%i\SubfolderA\
Please help.
PS: Script should copy a folder to other folders which have random names.
I think, I'm making some progress here:
for /d %%a in ("O:\*") do if exist "%%a" xcopy /t /e "M:\Folder1" %%a\SubfolderA
but I'm getting the error below.
Invalid number of parameters