
Robocopy, short for Robust File Copy, is built into Windows for file copies that are too large, slow, fragile, or repetitive for normal copy and paste. It can resume interrupted transfers, skip files already copied, keep timestamps, and write a log.
This guide applies to Windows 10 and Windows 11. Robocopy works from Command Prompt or PowerShell and does not require a download.
Does This Affect You?
Use Robocopy when copying a large folder, syncing a backup drive, moving thousands of files, or copying across an unreliable network. It is especially useful because you can rerun the same command and it copies only what is missing or changed.
Copy a Folder and Its Subfolders
This is the basic Robocopy pattern most people need. Replace the source and destination paths with your own.
- Click Start, type cmd, and open Command Prompt. Administrator rights are only needed for protected files or folders.
- Run a command like
robocopy "C:UsersYourNameDocuments" "D:BackupDocuments" /E. - The
/Eswitch copies all subfolders, including empty ones. Without it, Robocopy only copies the top-level files. - Read the summary when it finishes. Copied means transferred, Skipped means the destination already matched, and Failed needs attention.
- If the copy is interrupted, run the exact command again. Robocopy checks what already exists and continues from the differences.
Mirror Two Folders Exactly
Mirroring is useful for keeping a backup folder identical to the source, but it can delete files from the destination. Use it only when that is what you intend.
- Open Command Prompt.
- Run a command like
robocopy "C:UsersYourNameDocuments" "D:BackupDocuments" /MIR. - The
/MIRswitch copies new and changed files and deletes destination files that no longer exist in the source. - Add a log if you want a record, for example
/LOG:"C:UsersYourNameDesktoprobocopy-log.txt". - Rerun the command whenever you want to sync again. Only changed differences are processed.
Robocopy Switches Worth Knowing
/E includes subfolders, including empty folders. /MIR mirrors the destination to match the source, including deletions. /Z uses restartable mode for unstable network copies. /R:3 limits retries to three attempts. /W:5 waits five seconds between retries. /XO skips destination files that are newer than the source.
Robocopy Notes
Set Retry Limits
Robocopy’s default retry count is extremely high, which can make a job look stuck on one bad file. For unattended jobs, add something like /R:3 /W:5 so failed files do not stall the entire copy for a long time.
Exit Codes Are Not Simple
Robocopy exit codes combine several status flags, such as copied files, extra files, mismatches, and failures. For a manual copy, the summary is usually easier to read. Exit codes matter most when another script needs to react to the result.
Schedule a Backup Command
Once a Robocopy command is tested, save it in a .bat file and use Task Scheduler for a recurring local or network backup. Test without /MIR first if you are unsure about deletions.
Sources
- Microsoft Learn: Robocopy command-line reference
- Microsoft Support: Copy files and folders with Robocopy
- Microsoft Learn: Robocopy exit codes
