Whether you’re a system administrator, developer, or power user, having quick access to the most useful Robocopy commands can save hours of time and prevent costly mistakes. This comprehensive cheat sheet contains every essential Robocopy command you’ll need for daily file management tasks, organized by use case and difficulty level.

Bookmark this page and keep it handy for instant reference whenever you need to perform reliable, efficient file transfers in Windows. Each command includes practical examples and explanations to help you understand not just what to type, but when and why to use each option.
Quick Reference: Basic Robocopy Syntax
robocopy [source] [destination] [file(s)] [options]
Essential Components:
- Source: The folder you’re copying from
- Destination: The folder you’re copying to
- Files: Specific files to copy (optional, defaults to all files)
- Options: Flags that control how the copy operation works
Basic Example:
robocopy "C:\MyFiles" "D:\Backup" /E /COPYALL
Most Common Robocopy Commands (Copy & Paste Ready)
1. Simple Folder Backup
# Copy all files and folders (including empty ones)
robocopy "C:\Source" "D:\Destination" /E
# Copy with all attributes and security settings
robocopy "C:\Source" "D:\Destination" /E /COPYALL
# Mirror source to destination (exact copy, deletes extra files)
robocopy "C:\Source" "D:\Destination" /MIR
2. Network File Transfers
# Basic network copy with resume capability
robocopy "C:\LocalFolder" "\\Server\SharedFolder" /E /Z /COPYALL
# Network copy with compression and multi-threading
robocopy "C:\LocalFolder" "\\Server\SharedFolder" /E /Z /COMPRESS /MT:8
# Reliable network sync with retry settings
robocopy "C:\LocalFolder" "\\Server\SharedFolder" /MIR /Z /R:5 /W:15
3. Fast Multi-Threaded Copying
# Use 8 threads for faster copying
robocopy "C:\Source" "D:\Destination" /E /MT:8
# Maximum speed for SSD to SSD transfers
robocopy "C:\Source" "D:\Destination" /E /MT:32 /J
# Optimized for many small files
robocopy "C:\Source" "D:\Destination" /E /MT:16 /COPYALL
4. Selective File Copying
# Copy only specific file types
robocopy "C:\Photos" "D:\Backup" *.jpg *.png *.gif /E
# Copy files modified in last 7 days
robocopy "C:\Documents" "D:\Recent" /E /MAXAGE:7
# Copy files larger than 1MB
robocopy "C:\Files" "D:\LargeFiles" /E /MIN:1048576
Essential Options Reference Guide
Directory Copy Options
Option | Description | Example Usage |
---|---|---|
/E | Copy subdirectories, including empty ones | robocopy C:\Source D:\Dest /E |
/S | Copy subdirectories, excluding empty ones | robocopy C:\Source D:\Dest /S |
/MIR | Mirror directory (copy + delete extra files) | robocopy C:\Source D:\Dest /MIR |
/PURGE | Delete destination files not in source | robocopy C:\Source D:\Dest /E /PURGE |
File Attribute Options
Option | Description | Example Usage |
---|---|---|
/COPYALL | Copy all file information (DATSOU) | robocopy C:\Source D:\Dest /E /COPYALL |
/COPY:flags | Specify what to copy (D=Data, A=Attributes, T=Timestamps, S=Security, O=Owner, U=Auditing) | robocopy C:\Source D:\Dest /E /COPY:DAT |
/SEC | Copy files with security (NTFS ACLs) | robocopy C:\Source D:\Dest /E /SEC |
/SECFIX | Fix file security on all files | robocopy C:\Source D:\Dest /E /SECFIX |
Performance Options
Option | Description | Example Usage |
---|---|---|
/MT:n | Multi-threaded copying (1-128 threads) | robocopy C:\Source D:\Dest /E /MT:8 |
/J | Unbuffered I/O (faster for large files) | robocopy C:\Source D:\Dest /E /J |
/COMPRESS | Request network compression | robocopy C:\Source \\Server\Share /E /COMPRESS |
/IPG:n | Inter-packet gap (ms) for bandwidth throttling | robocopy C:\Source D:\Dest /E /IPG:100 |
Task-Specific Command Collections
Daily Backup Commands
# Personal documents backup (safe, preserves everything)
robocopy "%USERPROFILE%\Documents" "D:\Backup\Documents" /MIR /COPYALL /R:3 /W:10
# Photos backup with date verification
robocopy "%USERPROFILE%\Pictures" "E:\PhotoBackup" /MIR /COPYALL /R:2 /W:5 /LOG:photo_backup.log
# Project files backup (excludes temp files)
robocopy "C:\Projects" "D:\ProjectBackup" /MIR /XD bin obj temp .git /XF *.tmp *.log
System Administration Commands
# User profile migration
robocopy "C:\Users\OldUser" "\\NewPC\C$\Users\NewUser" /E /COPYALL /XD "AppData\Local\Temp" /R:5 /W:10
# Server data synchronization
robocopy "\\Server1\Data" "\\Server2\Data" /MIR /COPYALL /SEC /R:10 /W:30 /LOG+:sync.log
# Software deployment
robocopy "\\DeployServer\Software" "C:\Temp\Install" /E /COPYALL /R:3 /W:5
Development and Testing Commands
# Source code backup (excludes build artifacts)
robocopy "C:\Code\MyProject" "D:\CodeBackup\MyProject" /MIR /XD bin obj .vs packages node_modules
# Database backup files
robocopy "C:\DatabaseBackups" "\\BackupServer\DBBackups" /E /MAXAGE:30 /MT:4 /LOG+:db_transfer.log
# Test data preparation
robocopy "\\TestDataServer\Datasets" "C:\TestData" /E /COPYALL /R:2 /W:5
Advanced Filtering Commands
Date-Based Filtering
# Files modified in last 30 days
robocopy "C:\Documents" "D:\Recent" /E /MAXAGE:30
# Files older than 1 year (for archiving)
robocopy "C:\OldFiles" "D:\Archive" /E /MINAGE:365
# Files not accessed in 90 days
robocopy "C:\Files" "D:\Unused" /E /MAXLAD:90
Size-Based Filtering
# Files between 1MB and 100MB
robocopy "C:\Files" "D:\MediumFiles" /E /MIN:1048576 /MAX:104857600
# Only large files (over 100MB)
robocopy "C:\Files" "D:\LargeFiles" /E /MIN:104857600
# Small files only (under 1MB)
robocopy "C:\Files" "D:\SmallFiles" /E /MAX:1048576
File Type Filtering
# Images only
robocopy "C:\AllFiles" "D:\Images" *.jpg *.jpeg *.png *.gif *.bmp *.tiff /E
# Documents only
robocopy "C:\AllFiles" "D:\Documents" *.doc *.docx *.pdf *.txt *.rtf /E
# Exclude temporary files
robocopy "C:\Source" "D:\Destination" /E /XF *.tmp *.temp *.log ~*.*
Logging and Monitoring Commands
Basic Logging
# Simple log file
robocopy "C:\Source" "D:\Dest" /E /LOG:copy.log
# Console output + log file
robocopy "C:\Source" "D:\Dest" /E /LOG:copy.log /TEE
# Append to existing log
robocopy "C:\Source" "D:\Dest" /E /LOG+:copy.log
Detailed Monitoring
# Comprehensive logging
robocopy "C:\Source" "D:\Dest" /E /LOG:detailed.log /V /TS /FP /BYTES
# Progress monitoring (minimal screen output)
robocopy "C:\Source" "D:\Dest" /E /NP /NFL /NDL
# Error-only logging
robocopy "C:\Source" "D:\Dest" /E /LOG:errors.log /NFL /NDL /BYTES
Log Analysis Commands
# Test run (show what would be copied)
robocopy "C:\Source" "D:\Dest" /E /L
# Statistics only
robocopy "C:\Source" "D:\Dest" /E /L /NJH /NJS /NP /NFL /NDL
# Differences between folders
robocopy "C:\Folder1" "C:\Folder2" /E /L /NJH /NJS
Error Handling and Retry Commands
Retry Configuration
# 5 retries with 10-second waits
robocopy "C:\Source" "D:\Dest" /E /R:5 /W:10
# No retries (fail fast)
robocopy "C:\Source" "D:\Dest" /E /R:0
# Save retry settings as default
robocopy "C:\Source" "D:\Dest" /E /R:3 /W:5 /REG
Network Resilience
# Restartable mode for network transfers
robocopy "C:\Local" "\\Server\Share" /E /Z /R:10 /W:30
# Network with compression and restartable mode
robocopy "C:\Local" "\\Server\Share" /E /Z /COMPRESS /R:5 /W:15
# Backup mode for permission issues
robocopy "C:\Source" "D:\Dest" /E /B /COPYALL
Specialized Use Case Commands
Mirror Synchronization
# Perfect mirror (dangerous - deletes files!)
robocopy "C:\Master" "D:\Mirror" /MIR /COPYALL
# Safe mirror with confirmation
robocopy "C:\Master" "D:\Mirror" /MIR /COPYALL /L
# (Review output, then remove /L to execute)
# Mirror with exclusions
robocopy "C:\Master" "D:\Mirror" /MIR /XD temp cache .git /XF *.tmp
Incremental Backups
# Copy only changed files
robocopy "C:\Data" "D:\Backup" /E /XO /COPYALL
# Archive bit-based incremental
robocopy "C:\Data" "D:\Backup" /E /M /COPYALL
# Date-based incremental (last 24 hours)
robocopy "C:\Data" "D:\Backup" /E /MAXAGE:1 /COPYALL
Monitoring and Automation
# Monitor source and copy changes (runs continuously)
robocopy "C:\Source" "D:\Dest" /E /MON:1 /MOT:60
# One-time monitoring check
robocopy "C:\Source" "D:\Dest" /E /MON:1
# Scheduled synchronization
robocopy "C:\Source" "D:\Dest" /MIR /MOT:1800
Performance Optimization Commands
Speed Optimization
# Maximum speed for local transfers
robocopy "C:\Source" "D:\Dest" /E /MT:32 /J /NP
# Optimized for many small files
robocopy "C:\Source" "D:\Dest" /E /MT:16 /NP /NFL
# Large file optimization
robocopy "C:\Source" "D:\Dest" /E /J /NP /BYTES
Network Optimization
# Bandwidth throttling (100ms between packets)
robocopy "C:\Source" "\\Server\Share" /E /IPG:100
# Compressed network transfer
robocopy "C:\Source" "\\Server\Share" /E /COMPRESS /MT:4
# Low-bandwidth network transfer
robocopy "C:\Source" "\\Server\Share" /E /IPG:500 /R:10 /W:60
Resource Management
# Low CPU usage
robocopy "C:\Source" "D:\Dest" /E /MT:2
# Minimal memory usage
robocopy "C:\Source" "D:\Dest" /E /NP /NFL /NDL
# Background processing (low priority)
robocopy "C:\Source" "D:\Dest" /E /MT:4 /LOW
Batch Script Integration
Basic Batch File Template
@echo off
echo Starting Robocopy operation...
set SOURCE=C:\SourceFolder
set DEST=D:\DestinationFolder
set LOGFILE=C:\Logs\robocopy_%date:~-4,4%%date:~-10,2%%date:~-7,2%.log
robocopy "%SOURCE%" "%DEST%" /MIR /COPYALL /R:3 /W:10 /LOG:"%LOGFILE%" /TEE
if %ERRORLEVEL% LEQ 1 (
echo Operation completed successfully
) else if %ERRORLEVEL% LEQ 3 (
echo Operation completed with minor issues
) else (
echo Operation failed - check log file: %LOGFILE%
)
pause
Advanced Error Handling
@echo off
setlocal EnableDelayedExpansion
set SOURCE=%1
set DEST=%2
if "%SOURCE%"=="" set SOURCE=C:\DefaultSource
if "%DEST%"=="" set DEST=D:\DefaultDest
echo Copying from %SOURCE% to %DEST%
robocopy "%SOURCE%" "%DEST%" /MIR /COPYALL /R:3 /W:10 /LOG:copy.log /TEE
set RESULT=%ERRORLEVEL%
if !RESULT! EQU 0 echo No files copied
if !RESULT! EQU 1 echo Files copied successfully
if !RESULT! EQU 2 echo Extra files found
if !RESULT! EQU 4 echo Mismatched files found
if !RESULT! EQU 8 echo Failed copies occurred
if !RESULT! GEQ 16 echo Fatal error occurred
endlocal
PowerShell Integration
Basic PowerShell Wrapper
# PowerShell function for common Robocopy operations
function Invoke-RobocopyBackup {
param(
[string]$Source,
[string]$Destination,
[string]$LogPath = "C:\Logs\robocopy-$(Get-Date -Format 'yyyyMMdd-HHmmss').log"
)
$Arguments = @(
$Source,
$Destination,
"/MIR",
"/COPYALL",
"/R:3",
"/W:10",
"/LOG:$LogPath",
"/TEE"
)
Start-Process -FilePath "robocopy" -ArgumentList $Arguments -Wait -NoNewWindow
}
# Usage
Invoke-RobocopyBackup -Source "C:\Documents" -Destination "D:\Backup"
Scheduled Task Integration
# Create scheduled task for daily backup
$Action = New-ScheduledTaskAction -Execute "robocopy" -Argument '"C:\Data" "D:\Backup" /MIR /COPYALL /LOG+:C:\Logs\daily_backup.log'
$Trigger = New-ScheduledTaskTrigger -Daily -At "2:00AM"
$Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
Register-ScheduledTask -TaskName "Daily Data Backup" -Action $Action -Trigger $Trigger -Settings $Settings
Common Error Solutions
Access Denied Errors
# Use backup mode
robocopy "C:\Source" "D:\Dest" /E /B /COPYALL
# Skip files with permission issues
robocopy "C:\Source" "D:\Dest" /E /COPYALL /R:0
# Copy without security information
robocopy "C:\Source" "D:\Dest" /E /COPY:DAT
Network Path Issues
# Use IP address instead of computer name
robocopy "C:\Local" "\\192.168.1.100\Share" /E /Z
# Map network drive first
net use Z: \\Server\Share
robocopy "C:\Local" "Z:\Folder" /E /COPYALL
Long Path Names
# Enable long path support (Windows 10/11)
robocopy "\\?\C:\VeryLongPath" "\\?\D:\Destination" /E
# Use shorter destination paths
robocopy "C:\Source" "D:\S" /E
Quick Exit Code Reference
Exit Code | Meaning | Action Required |
---|---|---|
0 | No files copied | Normal – no changes needed |
1 | Files copied successfully | Success |
2 | Extra files found | Review if using /MIR |
3 | Files copied + extras found | Usually success |
4 | Mismatched files | Check source/destination |
5 | Files copied + mismatched | Review differences |
6 | Extra + mismatched files | Review operation |
7 | Files copied + extra + mismatched | Check results |
8+ | Failed copies occurred | Check logs for errors |
Best Practices Checklist
Before Running Robocopy
- [ ] Test with
/L
option first (dry run) - [ ] Check available disk space at destination
- [ ] Verify source and destination paths exist
- [ ] Consider using
/MIR
carefully (it deletes files) - [ ] Plan for appropriate retry settings
During Operation
- [ ] Monitor progress and error messages
- [ ] Watch system resources (CPU, memory, disk)
- [ ] Be prepared to stop if issues arise
- [ ] Keep log files for review
After Operation
- [ ] Review exit codes and log files
- [ ] Verify critical files were copied correctly
- [ ] Check for any error patterns
- [ ] Update scripts based on lessons learned
Emergency Commands
Stop Runaway Robocopy
# Find Robocopy processes
tasklist | findstr robocopy
# Kill specific Robocopy process
taskkill /PID [process_id] /F
# Kill all Robocopy processes
taskkill /IM robocopy.exe /F
Quick Disaster Recovery
# Emergency backup of critical files
robocopy "C:\Critical" "D:\Emergency" /E /COPYALL /R:1 /W:1 /MT:8
# Rapid file restoration
robocopy "D:\Backup" "C:\Restore" /E /COPYALL /R:0 /MT:16
# Quick file verification
robocopy "C:\Original" "D:\Copy" /E /L /NJH /NJS
Conclusion
This cheat sheet covers the essential Robocopy commands you’ll need for 95% of your file transfer tasks. Bookmark this page and refer to it whenever you need to perform reliable, efficient file operations in Windows.
Remember to always test your commands with the /L
option first, especially when using /MIR
or /PURGE
. Start with basic commands and gradually incorporate advanced options as you become more comfortable with Robocopy’s capabilities.
For the latest updates and additional examples, keep this reference handy and don’t hesitate to experiment with different option combinations to find what works best for your specific use cases.