robocopy is a pretty good cmd utility to copy/mirror directories. I have been using it regularly now. One of the recent usages was to backup data.

robocopy /E /A /MT:4 d:\ f:\d_backup /XD d:\OneDrive /XF d:\pagefile.sys


  1. /E /A will cause it to mirror directory structure from source location d:\ to destination location f:\d_backup. It will create destination directory, if it does not exist.
  2. /MT:4 will direct robocopy to use 4 thread to copy- helps saturate io bandwith.
  3. /XD is for excluding directory from source and /XF is for excluding files from source. One can provide many locations and files- just that these need to come after source and destination locations. The entries for exclusion can be regex as well.

Similarly to just copy without overwriting anything:

robocopy <src> <dst> /E /XC /XN /XO


  1. /E will copy directories recursively
  2. /XC will exclude existing files with same timestamp, but different file sizes
  3. /XN will exclude existing files with newer timestamp
  4. /XO will exclude existing files with older timestamp

One thing I noticed is that, due to a certain bug, if robocopy creates the destination directory- it might create it hidden. It won’t show in explorer, but will be there if you go to that path. The simplest way to fix is to reset the attributes on this destination directory.

attrib -s -h f:\d_backup


Links of interest (click to expand..)
  1. robocopy documentation
  2. attrib documentation
  3. robocopy the ultimate
  4. robocopy technet MS
  5. robocopy examples
  6. hitchhikers-guide-to-robocopy