How To Use The Robocopy Command In Windows (2026)
Robocopy copies files and folders from one location to another and can resume, retry and log the job for you.
The basic form is robocopy <source> <destination> [options], typed in Command Prompt.
This guide uses Microsoft’s robocopy reference, so every option and exit code below is documented.
Table of Contents
- Robocopy quick answers
- The robocopy syntax
- Run robocopy
- Copy a folder and its subfolders
- What gets copied by default
- Mirror a folder and the risk of /mir
- Make large copies faster and safer
- Choose which files to copy
- Move instead of copy
- Skip files that already exist
- Limit how much bandwidth a copy uses
- Save a job and watch a folder
- Junctions, links and the volume root
- Retries and waiting
- Log the job
- Robocopy exit codes
- Official source
- More Windows guides
Robocopy quick answers
| I want to | Type this |
|---|---|
| Copy a folder with all subfolders | robocopy C:\Source D:\Backup /E |
| Mirror a folder exactly | robocopy C:\Source D:\Backup /MIR |
| Copy faster with several threads | robocopy C:\Source D:\Backup /E /MT:16 |
| Preview without copying | robocopy C:\Source D:\Backup /E /L |
| Save a log file | robocopy C:\Source D:\Backup /E /LOG:C:\Logs\copy.log |
The robocopy syntax
The syntax is robocopy <source> <destination> [<file>[ ...]] [<options>].
The source and destination are directories, not single files.
The optional file part names the files to copy, accepts the wildcards * and ?, and defaults to all files.
Microsoft’s own example copies one file: robocopy c:\reports "\\marketing\videos" yearly-report.mov /mt /z.
Microsoft warns that data copied from the root of a device makes the destination directory adopt the hidden and system attributes.
Run robocopy
- Press the Windows key and type cmd.
- Select Command Prompt.
- Type your robocopy command and press Enter.
Add quotation marks around any path that contains spaces.
To copy files you do not have rights to, first open Terminal as administrator.
Copy a folder and its subfolders
To bring subfolders along, add one of the switches Microsoft lists below.
| Option | What it does |
|---|---|
/s | Copies subdirectories but excludes empty directories. |
/e | Copies subdirectories and includes empty directories. |
/lev:<n> | Copies only the top n levels of the source tree. |
Microsoft’s first example is robocopy C:\Users\Admin\Records D:\Backup /E /ZB /LOG:C:\Logs\Backup.log.
What gets copied by default
The /copy:<flags> option picks which file properties to copy.
| Flag | Meaning |
|---|---|
| D | Data |
| A | Attributes |
| T | Timestamps |
| S | NTFS ACLs (security) |
| O | Owner information |
| U | Auditing information |
The default is DAT, which is data, attributes and timestamps.
/sec equals /copy:DATS, and /copyall equals /copy:DATSOU.
Mirror a folder and the risk of /mir
The /mir option mirrors a directory tree and is equivalent to /e plus /purge.
Microsoft says /purge deletes destination files and directories that no longer exist in the source.
That means a mirror removes anything in the destination that the source lacks.
Run the command with /l first, because that option lists what would happen without copying, deleting or timestamping anything.
Microsoft also notes that /mir with /e overwrites destination directory security settings.
Make large copies faster and safer
| Option | What it does |
|---|---|
/mt:<n> | Multi-threaded copy with n threads, 1 to 128, default 8. Microsoft recommends /log for better performance, and /mt cannot be combined with /ipg or /efsraw. |
/z | Restartable mode, which resumes an interrupted copy instead of recopying the whole file. |
/b | Backup mode, which overrides ACLs that might block access. |
/zb | Restartable mode that falls back to backup mode if access is denied. |
/j | Unbuffered I/O, recommended for large files. |
/ipg:<n> | Inter-packet gap, to free bandwidth on slow lines. |
If you only want to copy a handful of big files with no extras, our guide to copying large numbers of files quickly covers other approaches.
Choose which files to copy
| Option | What it does |
|---|---|
/xf <file> | Excludes files matching names or paths; wildcards allowed. |
/xd <dir> | Excludes directories matching names or paths. |
/xo | Excludes source files older than the destination copy. |
/xn | Excludes source files newer than the destination copy. |
/maxage:<n> | Excludes files older than n days or a date. |
/minage:<n> | Excludes files newer than n days or a date. |
/max:<n> | Excludes files larger than n bytes. |
/min:<n> | Excludes files smaller than n bytes. |
Move instead of copy
The /mov option moves files and deletes them from the source after copying.
The /move option does the same for files and directories.
Microsoft’s example moves files and subdirectories, leaves out empty ones and skips files older than seven days: robocopy C:\Users\Admin\Records D:\Backup /S /MAXAGE:7 /MOV /LOG:C:\Logs\Backup.log.
Skip files that already exist
Microsoft’s example for leaving existing files alone is robocopy C:\Source C:\Destination /XC /XN /XO.
Those switches exclude files with the same timestamp but a different size, source files newer than the destination copy, and source files older than it.
The result is that files already in the destination are skipped, regardless of age or modification.
Limit how much bandwidth a copy uses
Microsoft’s example robocopy C:\Records D:\Backup /iorate:1m limits I/O to 1 MB per second.
The /iomaxsize, /iorate and /threshold options control throttling.
Microsoft says the minimum throttled I/O bandwidth is 524288 bytes, even if you specify a lower value.
Save a job and watch a folder
| Option | What it does |
|---|---|
/save:<jobname> | Saves parameters to a job file; put all copy, retry and logging options before this switch. |
/job:<jobname> | Loads parameters from a saved job file. |
/quit | Exits after parsing the command line, which helps you check parameters. |
/mon:<n> | Monitors the source and runs again after n changes. |
/mot:<m> | Monitors the source and runs again after m minutes if changes are detected. |
Junctions, links and the volume root
The /sj option copies junctions as junctions instead of following their targets.
The /sl option does not follow symbolic links and copies the link itself.
The /xj option excludes junction points, which are included by default.
When you use /purge or /mir on a volume root, Microsoft says robocopy now skips any files or directories named System Volume Information in the top-level source and destination.
Even so, avoid pointing a mirror at a drive root unless you have checked the destination first.
Retries and waiting
The /r:<n> option sets how many times robocopy retries a failed copy, and the default is 1,000,000.
The /w:<n> option sets the wait between retries in seconds, and the default is 30.
With those defaults, a locked file can hold up a job for a very long time, so set smaller values such as /r:2 /w:5.
Log the job
| Option | What it does |
|---|---|
/log:<file> | Writes output to a log file, overwriting it. |
/log+:<file> | Appends to an existing log file. |
/tee | Writes to the console and the log file. |
/np | Hides the progress percentage. |
/eta | Shows the estimated time of arrival. |
/l | Lists files only, without copying. |
Microsoft recommends a log file for every job so you can verify the results.
Robocopy exit codes
| Code | Meaning |
|---|---|
| 0 | No files copied, no failures, no mismatches; files already exist in the destination. |
| 1 | All files copied successfully. |
| 2 | Extra files in the destination; no files copied. |
| 3 | Some files copied, extra files present, no failures. |
| 5 | Some files copied, some mismatched, no failures. |
| 6 | Extra and mismatched files; no files copied. |
| 7 | Files copied, with mismatches and extra files. |
| 8 | Several files did not copy. |
Microsoft states that any value of 8 or higher means at least one failure.
Official source
All options above come from Microsoft’s robocopy reference.
Its syntax notation is explained in the Command-Line Syntax Key.
More Windows guides
- How To Uninstall ESET From Windows Step By Step (2026)
- How To Uninstall Kaspersky Completely From Windows (2026)
- Local Security Authority Protection Is Off In Windows 11 (2026)
- How To Use Ping And Tracert In Windows 11 (2026)
- How To Change UAC Settings In Windows 11 (2026)
- How To Rip A CD To Your PC In Windows 11 (2026)
See all: Windows 11 Guides