What is RoboCopy and how to use RoboCopy (with examples)

Stefan
What is RoboCopy and how to use RoboCopy (with examples)

If you have been working in IT for some time or are interested in computers, you may have seen or heard the term RoboCopy.

What is robocopy?

Robocopy stands for “Robust File Copy”. It is a command-line tool for replicating directories and/or files. Microsoft introduced it in the Windows NT 4.0 operating system and it is still available in Windows 10 and Windows 11.

What can you do with robocopy?

You can use Robocopy to copy files and folders from one location to another. It is especially useful for copying large data sets, as it is faster and more reliable than standard copy commands.

It can also be used to create a folder and copy all its contents, including subfolders and file attributes, to another folder. This is useful for backing up data and ensuring consistency between different storage solutions.

Robocopy is a fairly comprehensive tool with many different functions and arguments you can apply to the app. In this guide, I'll explain what the functions and arguments mean and provide some examples using Robocopy.

How do you use robocopy?

To use Robocopy you need to open it in, for example, a Command Prompt. It is recommended to always run the Command Prompt as an administrator.

command prompt as administrator

To get all options and arguments for Robocopy, type

robocopy /?

You will then see a whole list of all the options and arguments you can use.

robocopy options

Main robocopy options

/S – Copies subdirectories except empty subdirectories.
/E – Copies subfolders including empty subfolders.
/LEV:n – Copies only the top n levels of the source folder tree.
/Z – Copies files in restartable mode.
/B – Copies files in backup mode.
/ZB – Uses restartable mode; if access is denied, backup mode is used.
/EFSRAW – Copies all encrypted files in EFS RAW mode.
/COPY:copyflags – Specifies the file properties to copy. The default is /COPY:DAT (Data, Attributes, Timestamp).
/DCOPY:copyflags – Specifies the folder properties to copy.
/SEC – Copy files with protection.
/COPYALL – Copy all file information.
/NOCOPY – Does not copy file information (useful with /PURGE).
/PURGE – Delete files and folders that no longer exist in the source.
/MIR – Mirrors a directory structure (similar to /E + /PURGE).

Read also
Install your own web server in Windows? This is how!

Robocopy file selection options

/A – Copies only files with the Archive attribute set.
/M – Copies only files with the archive attribute set and resets the attribute.
/IA:[RASHCNETO] – Includes only files with one of the specified attributes set.
/XA:[RASHCNETO] – Exclude files with one of the specified attributes.
/XF file [file]… – Exclude files that match the specified file names or paths.
/XD dir [dir]… – Exclude directories that match the specified names or paths.
/XC – Exclude modified files.
/XN – Exclude newer files.
/XO – Exclude older files.
/XX – Exclude additional files and directories.
/XL – Exclude “lonely” files and directories.
/IS – Includes the same files.
/IT – Includes “custom” files.
/MAX:n – Exclude files above the specified size.
/MIN:n – Exclude files under the specified size.
/MAXAGE:n – Exclude files older than n days/date.
/MINAGE:n – Exclude files newer than n days/date.
/MAXLAD:n – Exclude files that have not been used since n.
/MINLAD:n – Exclude files used since n (If n < 1900 then n = n days, otherwise n = YYYYMMDD date).

Robocopy logging options

/L – Shows files without copying, deleting, or timing them.
/X – Reports all additional files, not just the selected ones.
/V – Provides verbose output, with skipped files.
/TS – Include timestamps of source files in the output.
/FP – Include full path names of the files in the output.
/BYTES – Displays the size as bytes.
/NS – No size – do not log file sizes.
/NC – No class – do not log file classes.
/NFL – No file list – no logging file names.
/NDL – No dir list – no logging directory names.
/NP – No progress – do not show copied percentage.
/ETA – Shows the estimated time of arrival (ETA) of the copied files.
/LOG:file – Writes the status output to the log file (overwriting existing log).
/LOG+:file – Writes the status output to the log file (appends to existing log).
/UNILOG:file – Writes the status output to the log file as UNICODE (overwrite existing log).
/UNILOG+:file – Writes the status output to the log file as UNICODE (appends to existing log).
/TEE – Writes the status output to the console window and to the log file.
/NJH – No task header.
/NJS – No task overview.

Read also
Windows 11 Insider build 22572 – What's new?

Robocopy task options

/JOB:jobname – Includes parameters from the specified job file.
/SAVE:jobname – Saves parameters to the specified command file.
/QUIT – Exit after command line processing (to view parameters).
/NOSD – No source directory was specified.
/NODD – No destination directory was specified.
/IF – Includes files that meet the specified condition.

Robocopy repeat options

/R:n – Specifies the number of attempts on failed copies. The default value is 1 million, but -1 indicates an unlimited number of attempts.
/W:n – Specifies the wait time between attempts in seconds. The default setting is 30 seconds.

Robocopy examples

I have made a summary of the most commonly used examples for robocopy. This is the list:

Copy a directory and its contents

Copy all files and folders from SourceFolder to DestinationFolder.

robocopy C:\BronMap C:\BestemmingMap /E

Copy files with a specific extension

Copy all .txt files from SourceDir to DestinationFolder.

robocopy C:\BronMap C:\BestemmingMap *.txt

Copy files while preserving attributes

Copy files while retaining their attributes and NTFS ACLs (Access Control Lists).

robocopy C:\BronMap C:\BestemmingMap /COPY:DATSOU /E

Copy files and restart if job fails

Copy files and have the option to resume copying if the job fails or is paused.

robocopy C:\BronMap C:\BestemmingMap /Z

Mirror a folder

Mirroring a folder, which means that the destination folder exactly matches the source folder.

robocopy C:\BronMap C:\BestemmingMap /MIR

Copy files and generate a log file

Copy files and generate a log file that records the details of the copy operation.

robocopy C:\BronMap C:\BestemmingMap /LOG:C:\Pad\naar\logbestand.txt

Copy files modified after a certain date

Copy files that were modified after a certain date (in this case, after January 1, 2023).

robocopy C:\BronMap C:\BestemmingMap /MAXAGE:20230101

Copy files with verification (verbose)

Copy files and then verify that the files were copied correctly.

robocopy C:\BronMap C:\BestemmingMap /V

Copy only new and changed files

Copy only new and changed files, skipping files that already exist at the destination and have not been changed.

robocopy C:\BronMap C:\BestemmingMap /XO

Copy files with progress view

Copy files while showing progress at Command Prompt.

robocopy C:\BronMap C:\BestemmingMap /NP

Copy files over a network

Copy all files from a network share to a local folder.

robocopy \\NetwerkDeelbronDir C:\LokaleDir /E

Copy files while preserving file attributes

Copy all files while preserving file attributes such as timestamps and NTFS permissions.

robocopy C:\BronMap C:\BestemmingMap /COPYALL

Exclude specific files

Copy all files except those with the extensions .txt and .jpg.

robocopy C:\BronMap C:\BestemmingMap /XF *.txt *.jpg

Exclude specific folders

Read also
Create a shortcut in Windows 11? These are the ways

Copy all contents except (for example) the “temp” and “backup” folders.

robocopy C:\BronMap C:\BestemmingMap /XD temp backup

Use wildcards

Copy all files starting with “report” (of any file extension).

robocopy C:\BronMap C:\BestemmingMap rapport*.*

Copy only new and changed files

Copy only the files that are newer or have changed in the source folder since the last copy action.

robocopy C:\BronMap C:\BestemmingMap /MIR /XO

Copy files that have been modified in the last 7 days

Copy only the files that have been changed in the last 7 days. You can of course adjust the days as desired.

robocopy C:\BronMap C:\BestemmingMap /MAXAGE:7

Copy folder tree structure

Copy only the folder structure (without the files).

robocopy C:\BronMap C:\BestemmingMap /E /XF *.*

Copy only files modified after a specific date

Copy files that were changed after, for example, January 1, 2023.

robocopy C:\BronMap C:\BestemmingMap /MAXLAD:20230101

These were all examples you could use for specific Robocopy actions. I hope to have informed you with this. Thank you for reading!


Problem solved?


Help other people too.
Share this article on a website, forum or via social media.

Join our new computer forum for questions and computer help.
Do you have a computer question?

The email address will not be published. Required fields are marked with *