How to Use Robocopy to Copy Files in Windows

Windows Robocopy file copy illustration

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.

  1. Click Start, type cmd, and open Command Prompt. Administrator rights are only needed for protected files or folders.
  2. Run a command like robocopy "C:UsersYourNameDocuments" "D:BackupDocuments" /E.
  3. The /E switch copies all subfolders, including empty ones. Without it, Robocopy only copies the top-level files.
  4. Read the summary when it finishes. Copied means transferred, Skipped means the destination already matched, and Failed needs attention.
  5. 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.

  1. Open Command Prompt.
  2. Run a command like robocopy "C:UsersYourNameDocuments" "D:BackupDocuments" /MIR.
  3. The /MIR switch copies new and changed files and deletes destination files that no longer exist in the source.
  4. Add a log if you want a record, for example /LOG:"C:UsersYourNameDesktoprobocopy-log.txt".
  5. 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
Disclosure: This post may contain affiliate links which means I may receive a commission for purchases made through links. I will only recommend products that I have personally used! Learn more on my Private Policy page.
A thoughtful woman reads a newspaper while enjoying coffee at an indoor workspace.

DEALWEEK

SUBSCRIBE AND GET 20% OFF YOUR NEXT ORDER! OFFER ENDS SOON - DON’T MISS OUT!

We don’t spam! Read our privacy policy for more info.

Shopping Cart