Categories
DOS & DOS Scripting Operating Systems

Robocopy to Copy Folders

There are numerous switches and options for Robocopy that are hard to get right if you're rushing into a task.

Here is a useful example:

robocopy src dest /MIR /R:3 /W:15 /REG /LOG:c:\temp\robocopy.log /NP /TEE /DCOPY:T /MT

/MIR = Copy the mirror structure

/R= Retry only # times.  This is important, the default is one million which effectively means that if there's one bad file in a huge batch, it will never complete.

/W= Wait time between retries.

/REG writes the the R and W settings to the registry as defaults

(Effectively, with the R, W and REG options I"m saying "If there's a problem copying a file it's probably a lost cause.  Try again if you must, but don't waste a lot of time on it.  And don't ask again about these options"'. )

/LOG = Write the results to a log file, I'll miss info if it scrolls out of the buffer.

/NP = don't display the percentage.  Benefits: it gives a visual indicator of progress on screen. Drawbacks: It clogs up the log file with a line for every report of progress, at 1 per every 0.1%.  Over a thousand log lines for every file is a bit much.

/TEE = Show the output on the screen as well as sending it to the log file.

/DCOPY:T = Copy folder timestamps

/MT[:n] = Multi-Threaded mode, where n indicates the number of threads to be used. By default, n is 8 when you use the /MT option, and can be any value from 1 to 128.