Copying 200 GB with File Explorer usually ends the same way: a file with a path too long, an error halfway and doubt about what was copied. Robocopy comes with Windows, retries on its own, logs everything and can resume where it stopped. This guide shows the options that really matter and the one that can delete data if misused.
In short
robocopy source destination /Ecopies everything, empty subfolders included, and on a second pass copies only what changed./MIRmakes the destination identical to the source, which includes deleting whatever does not exist in the source.- An exit code of 1 is not an error: only 8 and above means failures.
Why Robocopy instead of Explorer
| File Explorer | Robocopy | |
|---|---|---|
| If a file fails | Stops and asks | Retries and continues |
| Second copy of the same folder | Asks to replace | Skips what is already the same |
| Very long paths | May fail | Supported |
| Record of copies | No | Yes, with /LOG |
| Parallel copy | No | Yes, with /MT |
| Resume after network drop | No | Yes, with /Z |
| Automatable | No | Yes, in scripts and scheduled tasks |
Explorer is fine for a few files. For large copies, external drives, NAS or periodic backups, Robocopy is more reliable and tells you exactly what happened.
Basic syntax
Open Terminal, PowerShell or Command Prompt. The structure is:
robocopy "C:\Origen" "D:\Destino" [archivos] [opciones]

Without options, Robocopy copies only the files in the root folder, no subfolders. It is the first scare for many: run it, it finishes instantly and almost all data is missing.
To copy the full tree:
robocopy "C:\Usuarios\Ana\Fotos" "E:\Copia\Fotos" /E
/Scopies subfolders, but not empty ones./Ecopies subfolders including empty ones. Usually what you want.
If you repeat the command, Robocopy compares size and date and copies only new or changed files. A second pass on a huge folder takes seconds.
/MIR: sync, carefully

robocopy "C:\Proyectos" "E:\Copia\Proyectos" /MIR
/MIR equals /E plus /PURGE: it copies everything and deletes from the destination any file or folder not in the source. Perfect for an exact replica, and dangerous for three reasons:
- Source and destination swapped. Robocopy “syncs” your good folder with the old copy and deletes what is newer.
- Empty or wrong source. If the source is an unmounted drive or a mistyped empty folder, the destination ends up empty too.
- Destination with other data. Pointing
/MIRat the root of a drive holding other things removes everything not in the source.
What Robocopy deletes does not go to the Recycle Bin.
Protection is simple: run with /L first. It lists what it would do without copying or deleting.
robocopy "C:\Proyectos" "E:\Copia\Proyectos" /MIR /L
In the output, lines marked *EXTRA File or *EXTRA Dir are what would be deleted. If you see one you did not expect, stop.
Options for large copies and unstable networks
/Z: restartable mode
With /Z, if a large file copy is interrupted, Robocopy continues where it left off. Useful over networks or with multi-gigabyte files. In exchange it is a bit slower on fast local drives, so do not add it by habit.
/R and /W: retries
By default Robocopy retries each failing file a million times, waiting 30 seconds between attempts. With a locked file the copy hangs practically forever. Set sensible values:
robocopy "C:\Datos" "\\NAS\Copias\Datos" /E /R:3 /W:5
Three retries with five seconds cover short network drops. What still fails is logged.
/MT: multithreaded copy
/MT copies several files at once. Without a number it uses 8 threads; 1 to 128 allowed.
robocopy "C:\Datos" "E:\Datos" /E /MT:16
It shows most with many small files, especially to a NAS. With a few huge files on a mechanical drive it barely helps and may be worse as the disk jumps between files. Try 8 or 16 before going higher.
Exclude folders and files
/XD excludes folders and /XF files. They accept several values and wildcards:
robocopy "C:\Proyectos" "E:\Copia" /E /XD node_modules .git "Temp" /XF *.tmp *.log Thumbs.db
Name exclusions apply at any level. /XD node_modules excludes all folders with that name, not just the root one. To exclude a specific one, give its full path.
Important with /MIR: excluded items are not deleted from the destination for being excluded, because Robocopy ignores them both ways.
Logging: know what happened
robocopy "C:\Datos" "E:\Datos" /E /R:3 /W:5 /LOG:"C:\Logs\copia.txt" /NP /TEE
/LOG:filesaves output to a file, overwriting each time./LOG+:fileappends./NPremoves the progress percentage. Without it the log fills with unreadable percent lines./TEEalso shows output on screen.
At the end of the log there is a summary table with Copied, Skipped, FAILED and Extras for folders, files and bytes. Look at the failures column first; if not zero, search for ERROR in the file to see which failed and why.
Exit codes
Robocopy returns a number that is a sum of flags. It confuses script users, because almost all programs return 0 when fine and Robocopy does not.

| Code | Meaning |
|---|---|
| 0 | Nothing to copy: source and destination already match |
| 1 | Files copied successfully |
| 2 | Extra files or folders in the destination |
| 4 | Mismatched files; check the log |
| 8 | Some files or folders could not be copied |
| 16 | Serious error: nothing copied (missing path, no permission…) |
Values combine: 3 is 1 + 2 (copied files and extras in destination). Rule of thumb: 0 to 7 fine; 8 or more something failed.
In a .bat file:
robocopy "C:\Datos" "E:\Datos" /E /R:3 /W:5 /LOG:"C:\Logs\copia.txt" /NP
if %ERRORLEVEL% GEQ 8 (
echo Copy failed. Check the log.
exit /b 1
)
exit /b 0
In PowerShell the code is in $LASTEXITCODE:
robocopy "C:\Datos" "E:\Datos" /E /R:3 /W:5 /NP
if ($LASTEXITCODE -ge 8) { Write-Error "Robocopy failed ($LASTEXITCODE)" }
Backup template
For a replica of a folder on an external drive or NAS, this combination covers most cases:
robocopy "C:\Usuarios\Ana\Documentos" "E:\Copia\Documentos" /MIR /Z /R:3 /W:5 /MT:8 /XF *.tmp /LOG:"C:\Logs\copia-documentos.txt" /NP
Run it first with /L added and check the list. Once it works, schedule it with Task Scheduler to run nightly.
Common mistakes
- Trailing slash inside quotes.
"D:\Destination\"makes\"an escaped quote and Robocopy gets a broken path. Write"D:\Destination"without trailing slash, orD:\without quotes. - Forgetting
/Eand copying only the root folder. - Leaving
/Rand/Wdefault and watching the copy “hang” for hours on a locked file. - Using
/MIRwithout testing with/L, or with source and destination swapped. - Treating code 1 as an error in a script or Task Scheduler, which flags it as failure though all is fine.
- Files copied again and again on FAT32 or exFAT or some NAS. Those store time less precisely and Robocopy thinks files changed. Add
/FFTto accept a 2-second difference. - Files in use like an open Outlook
.pstor active databases. Robocopy cannot copy them while locked; close them first.



