Robocopy.exe is a command-line file copying utility built into Windows that copies files and folders faster and more reliably than standard copy methods. It can resume interrupted transfers, mirror directories, handle long file paths, and copy files with all their permissions and attributes intact.
If you’ve ever lost hours copying large folders, dealt with failed network transfers, or needed to backup thousands of files while preserving their exact structure, robocopy solves these problems better than any graphical tool.
What Is Robocopy and Why Should You Use It?
Robocopy stands for “Robust File Copy.” Microsoft included it in every Windows version since Vista. Before that, IT professionals downloaded it separately because nothing else worked as well.
Unlike dragging and dropping files in File Explorer, robocopy handles interruptions intelligently. Your network drops for ten seconds? Robocopy waits and resumes. A file is locked? It retries automatically. You need to copy 500,000 files? Robocopy does it without freezing.
Key advantages over regular copying:
Robocopy uses multi-threaded copying to transfer multiple files simultaneously. It skips files that already exist at the destination if they’re identical. It preserves NTFS permissions, timestamps, and file attributes that other tools lose. It creates detailed logs showing exactly what happened during the copy.
Network administrators use robocopy for server migrations. Photographers use it to backup photo libraries. Developers use it to sync code between machines. Anyone managing large amounts of data benefits from its reliability.

Getting Started: Your First Robocopy Command
Open Command Prompt or PowerShell as an administrator. The basic robocopy syntax looks like this:
robocopy source destination options
Simple example to copy a folder:
robocopy C:\Photos D:\Backup\Photos /E
This copies everything from C:\Photos to D:\Backup\Photos, including empty subfolders. The /E switch means “copy subdirectories, including empty ones.”
What happens when you run this:
Robocopy scans both locations. It compares file sizes and timestamps. It copies only files that are new or different. It shows you real-time progress with files per minute, bytes copied, and estimated time remaining.
The command completes and displays a summary table showing how many files were copied, skipped, or failed.
Essential Robocopy Switches You’ll Actually Use
Robocopy has over 80 command switches. You’ll use about 12 of them regularly. Here are the ones that matter most.
Copying Options
/E copies all subdirectories including empty ones. Use this for complete folder copies.
/MIR mirrors the source to destination, meaning it deletes files at the destination that don’t exist in the source. Perfect for exact backups but dangerous if you point it the wrong direction.
/COPYALL preserves all file information including data, attributes, timestamps, NTFS permissions, owner info, and auditing info. Essential for system migrations.
/DCOPY:T copies directory timestamps so folders show their original creation dates.
/Z enables restartable mode for network copies. If the transfer breaks, robocopy picks up where it left off instead of starting over.
/MT:16 uses 16 threads for faster copying. The number can be 1 to 128. Higher numbers help with many small files but may slow down single large files.
Selection Options
/MAXAGE:n only copies files newer than n days. Great for incremental backups.
/XO excludes older files, so robocopy won’t overwrite newer versions at the destination.
/XF excludes specific files. Example: /XF *.tmp *.log excludes temporary and log files.
/XD excludes specific directories. Example: /XD “C:\Photos\Draft” skips the Draft folder.
Logging and Monitoring
/LOG:file.txt writes output to a log file instead of the screen.
/TEE shows output on screen AND writes to log file simultaneously.
/NP removes the percentage progress indicator, useful when redirecting output.
/NFL /NDL removes file and directory lists from output, showing only the summary.
Real-World Robocopy Examples That Solve Actual Problems
Backup Your Documents Folder Daily
robocopy "C:\Users\YourName\Documents" "D:\Backups\Documents" /MIR /XD "node_modules" ".git" /R:2 /W:5 /LOG:"D:\Backups\log.txt"
This mirrors your Documents folder to an external drive, excludes development folders that contain thousands of tiny files, retries failed copies twice with 5 seconds between attempts, and logs everything.
Schedule this using Task Scheduler to run nightly. Your documents stay backed up automatically.
Copy Files Over an Unreliable Network
robocopy "\\NetworkServer\Share" "C:\LocalCopy" /E /Z /COPYALL /R:10 /W:30 /MT:8
The /Z switch enables restart mode. If your VPN drops, robocopy resumes without recopying finished files. The /R:10 /W:30 means retry 10 times with 30 seconds between attempts, perfect for flaky connections.
Sync Two Folders But Keep Deletions Safe
robocopy "C:\WorkFolder" "D:\WorkFolder_Backup" /E /XO /XF Thumbs.db
This copies new and updated files but never deletes anything at the destination. The /XO switch prevents overwriting newer files with older versions, protecting you from accidentally rolling back your work.
Migrate a User Profile to a New Computer
robocopy "C:\Users\OldUser" "\\NewComputer\C$\Users\NewUser" /E /COPYALL /DCOPY:T /R:5 /W:10 /LOG:"migration.txt" /TEE
This copies everything including permissions and timestamps. The /TEE switch shows progress on screen while logging to a file. You can verify the migration succeeded by reviewing the log later.
Understanding Robocopy Output and Exit Codes
When robocopy finishes, it displays a table that looks like this:
| Total | Copied | Skipped | Mismatch | Failed | Extras | |
|---|---|---|---|---|---|---|
| Dirs | 145 | 12 | 133 | 0 | 0 | 0 |
| Files | 2,847 | 156 | 2,691 | 0 | 0 | 0 |
| Bytes | 4.2 GB | 234 MB | 3.9 GB | 0 | 0 | 0 |
What each column means:
Total shows everything found at the source. Copied shows what robocopy transferred. Skipped shows identical files already at the destination. Mismatch shows files that exist but are different sizes. Failed shows copy errors. Extras shows files at the destination but not at the source.
Robocopy returns exit codes that scripts can check:
- 0 means no files copied, everything was already synchronized
- 1 means files were copied successfully
- 2 means extra files or directories were found
- 4 means some files were mismatched
- 8 means copy failures occurred
- 16 means serious errors like invalid parameters
Exit codes combine. If robocopy returns 3, that’s 1 + 2, meaning it copied files and found extras. A return code of 0 or 1 indicates complete success.
Advanced Techniques for Power Users
Create a Scheduled Backup Script
Save this as backup.bat:
@echo off
set SOURCE=C:\ImportantData
set DEST=D:\Backups\%date:~-4,4%-%date:~-10,2%-%date:~-7,2%
robocopy "%SOURCE%" "%DEST%" /MIR /XD temp cache /LOG:"%DEST%\backup.log" /TEE
if %ERRORLEVEL% LEQ 1 echo Backup completed successfully
This creates dated backup folders automatically and confirms success. Schedule it in Task Scheduler to run daily at 2 AM when you’re not using the computer.
Mirror Folders But Archive Deletions
robocopy C:\Current D:\Mirror /MIR /MOV D:\Archive
Wait, that’s wrong. Robocopy doesn’t have a /MOV switch. Here’s the correct approach:
robocopy C:\Current D:\Mirror /E /PURGE /MOV
Actually, robocopy lacks built-in deletion archiving. Use this two-step process:
First, move files that will be deleted:
robocopy D:\Mirror D:\Archive\Deleted /E /XO /MOV
robocopy C:\Current D:\Mirror /MIR
This moves obsolete files to an archive before mirroring. You can review deletions before purging the archive.
Use Robocopy with Long Path Names
Windows normally limits paths to 260 characters. Robocopy handles longer paths automatically in most cases, but for guaranteed support use:
robocopy "\\?\C:\Very\Long\Path\That\Exceeds\Windows\Limits" "\\?\D:\Destination" /E
The \?\ prefix enables extended-length path support for paths up to 32,767 characters.
Common Robocopy Mistakes and How to Avoid Them
Forgetting the Trailing Slash Issue
Robocopy treats paths differently based on trailing slashes:
robocopy C:\Source D:\Dest
This creates D:\Dest\Source with contents inside.
robocopy C:\Source\ D:\Dest\
This copies Source contents directly into Dest.
Always be explicit about what you want to avoid creating unwanted nested folders.
Using /MIR Without Understanding It
The /MIR switch makes the destination identical to the source by deleting extra files. Point it backward accidentally and you’ll delete your source data.
Wrong and destructive:
robocopy D:\Backup C:\Data /MIR
This makes C:\Data match the backup by deleting newer files. Always use /MIR carefully and test with /L first.
Not Testing with /L First
The /L switch runs robocopy in list-only mode. No files copy. You see exactly what would happen.
robocopy C:\Source D:\Dest /MIR /L
Review the output. If it looks wrong, fix your command. If it looks right, run it again without /L.
Ignoring Return Codes in Scripts
Scripts that don’t check robocopy’s exit code might report success when copies failed:
robocopy C:\Source D:\Dest /E
if %ERRORLEVEL% GEQ 8 (
echo Copy failed!
exit /b 1
)
Exit codes 8 and higher indicate failures. Check them in automated scripts.
Performance Tuning for Different Scenarios
Many Small Files
robocopy Source Dest /E /MT:32 /R:1 /W:1
Use more threads (up to 128) for thousands of small files. Reduce retry attempts because small files copy quickly.
Few Large Files
robocopy Source Dest /E /MT:1 /J
Single-threaded copying works better for large files. The /J switch uses unbuffered I/O for huge files (over 256 MB), which is faster for sequential reads.
Network Copies Over Slow Connections
robocopy Source Dest /E /Z /R:5 /W:15 /IPG:100
The /IPG:100 switch adds 100 milliseconds between packets, preventing network saturation. Useful for copying while others use the network.
SSD to SSD Local Copies
robocopy Source Dest /E /MT:8 /J /R:0 /W:0
SSDs handle multiple threads well. Unbuffered I/O avoids cache overhead. Zero retries because local SSD failures are rare.
Security and Permissions with Robocopy
Robocopy handles NTFS permissions better than any graphical tool. Understanding the security switches prevents permission headaches.
Copy Files Only (No Permissions)
robocopy Source Dest /E /COPY:DT
The /COPY:DT switch copies only data and timestamps. Files inherit permissions from the destination folder. Use this when moving files between different domains or security contexts.
Copy Everything Including Permissions
robocopy Source Dest /E /COPYALL /SEC
The /SEC switch is shorthand for /COPY:DATSOU (data, attributes, timestamps, security, owner, auditing). Use this for server migrations where preserving exact permissions matters.
Reset Permissions to Inherit from Parent
robocopy Source Dest /E /COPY:DT /DCOPY:T
Files inherit destination permissions while preserving timestamps. Useful when restructuring folder hierarchies with different permission schemes.
Robocopy vs. Other Copy Methods
Understanding when robocopy outperforms alternatives helps you choose the right tool.
Robocopy vs. File Explorer Copy
File Explorer copies files one at a time. It fails completely if interrupted. It can’t resume. It provides no log. It’s fine for a few files but terrible for anything serious.
Robocopy copies multiple files simultaneously, resumes after interruptions, logs everything, and completes reliably.
Robocopy vs. Xcopy
Xcopy is an older command-line tool that Microsoft replaced with robocopy. Xcopy can’t copy files in use, doesn’t multi-thread, and lacks restart capability.
Use robocopy instead. Every xcopy task works better with robocopy. Microsoft hasn’t updated xcopy since Windows XP.
Robocopy vs. PowerShell Copy-Item
Copy-Item works well for simple scripts but lacks robocopy’s retry logic, restart capability, and performance optimization. It’s easier to read in PowerShell scripts but slower and less reliable for large operations.
Use Copy-Item for small tasks in PowerShell scripts. Use robocopy for anything involving lots of data or network copies.
Robocopy vs. Third-Party Sync Tools
Tools like FreeFileSync and SyncBackFree provide graphical interfaces for the same operations. They’re easier for casual users but slower than robocopy and add software dependencies.
If you’re comfortable with command-line tools, robocopy is faster and already installed. For users who prefer clicking buttons, third-party tools are friendlier.
Automating Robocopy with Task Scheduler
Running robocopy manually defeats the purpose. Automation ensures backups happen consistently.
Create a Basic Scheduled Task
- Open Task Scheduler (search for it in the Start menu)
- Click “Create Basic Task” in the right panel
- Name it “Daily Document Backup”
- Choose “Daily” and set your preferred time
- Select “Start a program”
- Browse to C:\Windows\System32\robocopy.exe
- Add arguments: “C:\Users\YourName\Documents” “D:\Backup\Documents” /MIR /LOG:”D:\Backup\log.txt”
The task runs automatically every day. Check the log file to verify success.
Run Only When Idle
In Task Scheduler, after creating the task, right-click it and select Properties. Go to the Conditions tab. Check “Start the task only if the computer is idle for 10 minutes.”
This prevents robocopy from slowing down your work. It waits until you’re not actively using the computer.
Email Notifications on Failure
Task Scheduler can email you when tasks fail. You’ll need an SMTP server configured. For most users, checking logs manually is simpler and more reliable.
Instead, create a wrapper script that checks robocopy’s exit code and writes “SUCCESS” or “FAILED” to a status file you can review periodically.
Troubleshooting Common Robocopy Problems
“Access Denied” Errors
Run Command Prompt as Administrator. Right-click Command Prompt and choose “Run as administrator.” Many system folders require elevated privileges.
If you still get access denied errors, check folder permissions. You might lack rights to the source or destination.
Files Appear to Copy But Aren’t at the Destination
Check that you didn’t create an unexpected nested folder structure. Robocopy’s path handling sometimes creates extra folder levels.
Run robocopy with /L to see what would happen without actually copying. This reveals structure issues before committing to the copy.
Robocopy Runs Forever
If robocopy seems stuck, it might be retrying a failed file indefinitely. The default is 1 million retries with 30-second waits between them.
Cancel with Ctrl+C and add /R:5 /W:5 to limit retries to 5 attempts with 5 seconds between.
Network Copies Fail Randomly
Network issues cause most robocopy failures. Add /Z for restart mode and increase retry settings: /R:10 /W:30.
For persistent network problems, copy to a local drive first, then move to the network location. This isolates network issues from the main copy operation.
Destination Runs Out of Space
Robocopy doesn’t check available space before starting. It fails when the destination fills up. Use /MAX:n to skip files larger than n bytes, or free up space before copying.
To learn more about advanced Windows system administration, visit Microsoft’s official documentation for comprehensive technical details. For backup best practices, the Backup and Recovery Guide from Backblaze offers excellent strategies.
Conclusion
Robocopy.exe transforms file copying from a frustrating chore into a reliable automated process. Its command-line interface intimidates some users initially, but the power and reliability justify the learning curve.
Start with simple commands like /E for complete folder copies. Add /MIR when you need exact mirrors. Use /MT for speed with many files. Enable /Z for network resilience. Log everything with /LOG so you can verify success.
The dozen switches covered in this guide handle 95% of real-world copying needs. Master these fundamentals before exploring robocopy’s more obscure options.
Your time is valuable. Robocopy saves hours by doing file management correctly the first time. It prevents data loss by handling interruptions gracefully. It automates backups so you stop worrying about losing files.
Install nothing. Learn a few commands. Gain a professional-grade file management tool that works reliably for decades.
Frequently Asked Questions
Is robocopy faster than normal copying in Windows?
Yes, robocopy is faster for most operations because it uses multi-threading and skips identical files. Copying 10,000 files with File Explorer might take 30 minutes. Robocopy with /MT:16 often completes the same task in 10 minutes. Single large files show less difference, but anything involving multiple files or folders benefits from robocopy’s optimization.
Can robocopy copy files that are currently in use?
Sometimes. Robocopy cannot copy files locked exclusively by other programs. Database files and open documents usually fail to copy. However, the Volume Shadow Copy Service (VSS) can snapshot locked files. Use the /B backup mode switch to attempt copying files through VSS, though this requires administrator rights and doesn’t always succeed with heavily locked files.
Does robocopy work on network drives and cloud storage?
Robocopy works perfectly with network drives accessed through UNC paths like \server\share. It works with mapped network drives like Z:. Cloud storage depends on implementation. If the cloud service appears as a local drive (like OneDrive or Google Drive with their sync clients), robocopy works normally. Direct cloud APIs require different tools.
What happens if I accidentally run robocopy with /MIR pointing the wrong direction?
Robocopy immediately starts making the destination match the source, which means deleting files that don’t exist at the source. Press Ctrl+C to stop it as fast as possible. Deleted files go to the Recycle Bin only if you’re copying within the same drive. Network copies and different drives delete permanently. Always test /MIR commands with /L first to verify they do what you expect.
Can I use robocopy to copy only new files for incremental backups?
Yes, robocopy excels at incremental backups. Use /E with /XO to copy only files newer than those at the destination. Use /MAXAGE:7 to copy only files modified in the last 7 days. Combine these switches for fine-grained control over what gets backed up. For example, /E /XO /MAXAGE:30 /XF *.tmp copies everything newer at the source within the last 30 days while excluding temporary files.
- How to Fix Miracast Connection Issues on Windows 11/10 - April 17, 2026
- How to Improve Laptop Boot Performance on Windows 11/10: Speed Up Boot Time - April 15, 2026
- How to Do a Hanging Indent in Google Docs: Step-by-Step Guide - April 14, 2026
