Skip to main content

Robocopy Cheat Sheet

Robocopy is a command-line tool used for file replication. It is available in Windows operating systems and is used to copy large files or large amounts of files from one location to another.

Syntax

ROBOCOPY source_folder destination_folder [file(s)_to_copy] [options]
  • source_folder: Specifies the folder that contains the files to copy.
  • destination_folder: Specifies the destination folder for the copied files.
  • file(s)_to_copy: Specifies the file(s) to be copied. You can use wildcard characters to specify multiple files.
  • options: Specifies the options to use when copying the files.

Options

Copy Options

OptionDescription
/SCopies subdirectories.
/ECopies subdirectories, including empty ones.
/LEV:nCopies only the top n levels of the source directory tree.
/ZCopies files in restartable mode.
/BCopies files in backup mode (backup operator privileges required).
/ZBUses restartable mode; if access is denied, Robocopy will use backup mode.
/COPY:copyflagCopies file information specified by copyflag. You can specify multiple copyflag values separated by commas.
/DCOPY:copyflagCopies directory information specified by copyflag. You can specify multiple copyflag values separated by commas.
/TIMFIXFixes file times to prevent timestamp drift.
/PURGEDeletes destination files or directories that no longer exist in the source.
/MIRMirrors a directory tree (copies all files, including empty directories). Deletes files in the destination that are no longer in the source.
/MT[:n]Specifies the number of threads to use when copying files. The default is 8 threads.

Retry Options

OptionDescription
/R:nSpecifies the number of times that Robocopy should retry copying a file. The default is 1 million retries.
/W:nSpecifies the time, in seconds, that Robocopy should wait between retries. The default is 30 seconds.
/REGSaves retry information to the system registry instead of a file.

Logging Options

OptionDescription
/LDisplays the files that would be copied, but does not copy them.
/XExcludes files that match specified names or paths.
/XCExcludes changed files.
/XNExcludes newer files.
/XOExcludes older files.
/XXExcludes extra files and directories.
/XLExcludes "lonely" files and directories (those that are only in the source or destination, but not both).
/LOG:fileWrites the status output to a log file.
/LOG+:fileAppends the status output to a log file.
/TEEWrites the status output to the console window and to the log file.
/NJHSuppresses the "job header" in the status output.
/NJSSuppresses the "job summary" in the status output.
/UNILOG:fileWrites the status output to a log file in Unicode format.

Other Options

OptionDescription
/NFLSpecifies that file names should not be logged.
/NDLSpecifies that directory names should not be logged.
/NCSpecifies that file classes should not be logged.
/NSSpecifies that file sizes should not be logged.
/NPSpecifies that the progress of the copy operation should not be displayed.
/BYTESDisplays file sizes in bytes.
/KCopies file attributes.
/ACopies only files that have the archive attribute set.
/MCopies only files that have the archive attribute set, and resets the attribute.
/FFTUses FAT file timing instead of NTFS.
/256Uses 256-color mode.