I am trying to create a batch script to copy multiple directories in different locations into one single directory in another location. The problem is that robocopy is copying the internal contents of the root directory and not the root directory itself
So If I have 3 directories in location a being : C:\dir1 , C:\dir2 , C:\dir3
and I want to copy them to one single folder onto another location ex: D:\dirBackups
so that the outcome would be D:\dirBackups\dir1 , D:\dirBackups\dir2, D:\dirBackups/dir3
Currently robocopy is copying the stuff inside dir1 , dir2 and dir3 so I am ending up with the contents of the three directories all into D:\dirBackups
I am using the following code
for /F "tokens=*" %%A in (%pathsFile%) do (
robocopy %%A D:\dirBackups /E /COPYALL /XF /SEC /SECFIX /TIMFIX /W:0 /R:1 /REG /XJ /Z /FFT
)
%pathsFile% is a text file which contains the directories to be backed up into D:\dirBackups, so I am looping through the file and for each line I am triggering the same robocopy Command.
The files are getting copied well but the root directory is never included so it's working like it's expanding all the folders and only copying the inner content of each folder into one location.
Thanks
D:\dirBackupsnot a forward slashD:/dirBackups. Also you don't need to use/SEC, which is equivalent to/COPY:DATS, as you have already used/COPYALL, which is equivalent to/COPY:DATSOU. In addition your/XFoption does not name any files to exclude, enterROBOCOPY /?into a Command prompt window for more information on the command. - Compo