Using robocopy and excluding multiple directories
I figured it out with a little trial and error and the /L
(to test the command before doing it for real). The command I end up with is:
robocopy G: C:\backup /MIR /XD G:\dir1 "G:\dir 2" G:\dir3 ...
Apparently, including trailing slashes keeps robocopy from parsing the list of directories correctly, so be sure not to include trailing slashes on directory names and remember to put quotes around directories with spaces in the name.
The /MIR
option maintains the same directory structure while copying the files.
Edit: After some more research, I improved the command a bit:
robocopy G: C:\backup /MIR /Z /LOG:C:\todaysdate-backup.log /XF *.iso *.log *.au /XD G:\dir1 ...
The additions are as follows:
/Z
allows the job to be restarted/LOG:<logfile path>
is pretty self-explanatory./XF
is being used to exclude certain filetypes so it doesn't take so long
you have to repeat the /XD
part
C:\>robocopy "C:\Users\weberjn\Google Drive" "u:\Google Drive" /e /dcopy:t /copy:DT /r:0 /XD "C:\Users\weberjn\Google Drive\photos" /XD "C:\Users\weberjn\Google Drive\Google Photos"
I know this doesn't answer OP's question, but to anyone here from google: XD will fail in a job file if you use quotes.
Bad:
::
:: Exclude These Directories :
::
/XD :: eXclude Directories matching these names
"Temporary Internet Files"
Good:
::
:: Exclude These Directories :
::
/XD :: eXclude Directories matching these names
Temporary Internet Files
Place as many exclusions as you want, line after line, without using quotes (whether there are spaces or not).
The way I discovered this was by using the command line switch /SAVE:myjobname which took the quotes off my quoted directories!