Interactive PowerShell wrapper for robocopy with smart presets, logging, exclusions, and advanced utilities.
Script file: robocopy-enhance.ps1
# Interactive mode (easiest)
robocopy
# Quick mirror sync
robo-mirror C:\Source D:\Backup
# Quick backup (skip older)
robo-backup C:\Data D:\Backup
# Compare directories
robo-diff C:\Folder1 C:\Folder2
# Show help
robo-help
When you run robocopy without arguments, you get an interactive menu:
/MIR)/E)/MIR /XO)/E /MT:16)/E /V /ETA)/E /XO)Logs are saved to: %USERPROFILE%\Documents\robocopy-logs\
node_modules, .git, .svn, bin, obj*.tmp, *.log, Thumbs.db, .DS_Store/L)| Command | Usage | Description |
|---|---|---|
robo-mirror |
robo-mirror <src> <dst> |
Mirror sync (deletes extras) |
robo-backup |
robo-backup <src> <dst> |
Backup mode (skip older files) |
robo-sync |
robo-sync <src> <dst> |
Sync without deletions |
robo-fast |
robo-fast <src> <dst> |
Fast copy with minimal logging |
robo-verify |
robo-verify <src> <dst> |
Copy with verification |
robo-diff |
robo-diff <src> <dst> |
Compare two directories |
robo-stats |
robo-stats <path> |
Show directory statistics |
robo-schedule |
robo-schedule <src> <dst> [time] |
Create scheduled backup task |
robo-watch |
robo-watch <src> <dst> [interval] |
Watch and auto-sync changes |
# Interactive mode
robocopy
# Quick mirror (identical copy)
robo-mirror C:\Projects D:\Backup\Projects
# Backup without deleting destination files
robo-sync C:\Documents E:\Backup\Documents
# Fast copy for large datasets
robo-fast D:\Videos E:\Media\Videos
# Compare before copying
robo-diff C:\OldData C:\NewData
# Get statistics
robo-stats C:\MyFolder
# Schedule daily backup at 2 AM
robo-schedule C:\Important D:\Backup\Important 02:00
# Watch and sync every 30 seconds
robo-watch C:\DevFolder D:\Backup\DevFolder 30
# Verified copy with statistics first
robo-stats C:\Source
robo-verify C:\Source D:\Destination
# First run - configure your preferences
robocopy
# Choose preset, logging, exclusions
# Save settings when prompted
# Next runs - use saved settings instantly
robocopy
# Select option 1 to use saved settings
# Or option 3 for quick defaults
Robocopy uses bit-flag exit codes:
| Code | Meaning |
|---|---|
| 0 | No changes needed - files already match |
| 1 | Files copied successfully |
| 2 | Extra files/directories detected in destination |
| 4 | Mismatches detected between source and destination |
| 8+ | Errors occurred during copy |
Combined codes: Exit code 3 means both 1 and 2 (files copied + extras found)
/MIR)/MIR /R:3 /W:5 /MT:8 /V/E)/E /R:3 /W:5 /MT:8 /V/MIR /XO)/MIR /DCOPY:DAT /COPY:DAT /R:3 /W:5 /MT:8 /XO /V/MT:16)/E /R:1 /W:1 /MT:16 /NFL /NDL /NJH /NJS/V)/E /R:3 /W:5 /MT:8 /V /ETA/XO)/E /XO /R:3 /W:5 /MT:8 /VAutomatically excludes:
node_modules - Node.js packages.git - Git repository.svn - SVN repositorybin - Binary outputobj - Object filesAutomatically excludes:
*.tmp - Temporary files*.log - Log filesThumbs.db - Windows thumbnail cacheDesktop.ini - Windows folder settings.DS_Store - macOS folder settingsSpecify your own patterns:
# During interactive mode, choose option 5
# Then enter patterns like:
# Folders: cache temp downloads
# Files: *.bak *.old *.backup
Create automated backup tasks:
# Daily backup at 2 AM
robo-schedule C:\Important D:\Backup\Important 02:00
# Daily backup at 11 PM
robo-schedule C:\Projects D:\Backup\Projects 23:00
# View/modify in Task Scheduler
taskschd.msc
The scheduled task will:
Continuously monitor and sync changes:
# Sync every 60 seconds (default)
robo-watch C:\ActiveFolder D:\BackupFolder
# Sync every 30 seconds
robo-watch C:\DevFolder D:\BackupFolder 30
# Press Ctrl+C to stop
Use cases:
Saved to: %USERPROFILE%\Documents\robocopy-logs\
Format: robocopy_YYYYMMDD_HHMMSS.log
Example: robocopy_20250121_143052.log
# Open log directory
explorer "$env:USERPROFILE\Documents\robocopy-logs"
# View latest log
notepad (Get-ChildItem "$env:USERPROFILE\Documents\robocopy-logs" | Sort-Object LastWriteTime -Descending | Select-Object -First 1).FullName
| Flag | Description |
|---|---|
/E |
Copy subdirectories, including empty ones |
/MIR |
Mirror directory tree (includes deletions) |
/MT:n |
Multi-threaded copying (n = threads, default 8) |
/R:n |
Number of retries on failed copies |
/W:n |
Wait time between retries (seconds) |
/XO |
Exclude older files (skip if source is older) |
/XF |
Exclude files matching pattern |
/XD |
Exclude directories matching pattern |
/V |
Verbose output with verification |
/NP |
No progress - donโt display percentage |
/LOG:file |
Write log to file (overwrite) |
/LOG+:file |
Write log to file (append) |
/L |
List only - donโt copy, delete, or timestamp |
/ETA |
Show estimated time of arrival |
/DCOPY:DAT |
Copy directory attributes, timestamps |
/COPY:DAT |
Copy file data, attributes, timestamps |
# Run PowerShell as Administrator
# Or adjust NTFS permissions on source/destination
icacls "C:\Path" /grant:r "Username:(OI)(CI)F" /T
# Use fast mode for big files
robo-fast C:\LargeData D:\Backup
# Or adjust retries/wait time in custom mode
# Flags: /R:10 /W:30 (10 retries, 30 sec wait)
# Use UNC paths
robo-mirror "C:\Local" "\\Server\Share\Backup"
# Map network drive first if needed
net use Z: \\Server\Share /persistent:yes
robo-mirror "C:\Local" "Z:\Backup"
# Increase threads for SSDs
# Custom flags: /MT:32
# Decrease threads for HDDs to avoid thrashing
# Custom flags: /MT:4
# Disable logging for max speed
robo-fast C:\Source D:\Dest
# Schedule with backup preset
robo-schedule C:\Important D:\Backup 02:00
# Or use incremental for speed
# Manual: robocopy with preset 6 (Incremental)
# Exclude dev folders
robocopy
# Choose Sync preset (2)
# Choose Dev exclusions (2)
# Use fast mode
robo-fast D:\Photos E:\Backup\Photos
# Or mirror if you want exact replica
robo-mirror D:\Photos E:\Backup\Photos
# Full mirror backup
robo-mirror C:\ D:\SystemBackup
# Exclude system files
# During interactive mode:
# - Choose Mirror preset
# - Choose System exclusions
During interactive mode, youโll be prompted to save:
Saved to: %USERPROFILE%\.robocopy-settings.json
Next time you run robocopy:
robo-reset-settings
/L flag)/MT:32)/MT:4)# Show all commands
robo-help
# Interactive mode
robocopy
# Quick commands
robo-mirror <src> <dst>
robo-backup <src> <dst>
robo-sync <src> <dst>
robo-fast <src> <dst>
robo-verify <src> <dst>
# Analysis
robo-diff <src> <dst>
robo-stats <path>
# Advanced
robo-schedule <src> <dst> [time]
robo-watch <src> <dst> [interval]
robo-reset-settings
robo-diff before robo-mirrorrobo-stats to estimate copy time# 1. Check what you're backing up
robo-stats C:\Important
# 2. Compare first (if destination exists)
robo-diff C:\Important D:\Backup\Important
# 3. Test run
robocopy # Choose dry run option
# 4. Execute
robocopy # Choose start copy
# 5. Schedule for automation
robo-schedule C:\Important D:\Backup\Important 02:00
# 1. Initial sync (exclude dev folders)
robocopy
# Source: C:\Projects
# Dest: D:\Backup\Projects
# Preset: Sync (2)
# Exclusions: Dev folders (2)
# Save settings: Y
# 2. Daily quick syncs (use saved settings)
robocopy # Option 1 (use saved)
# 3. Watch mode during active development
robo-watch C:\Projects\Active D:\Backup\Active 60
# 1. Check size first
robo-stats D:\Photos
# 2. Fast initial copy
robo-fast D:\Photos E:\Backup\Photos
# 3. Schedule weekly updates
robo-schedule D:\Photos E:\Backup\Photos 23:00
Solution: Adjust retry settings in custom mode
# Custom flags: /R:10 /W:30
Solution: Check Task Scheduler settings
taskschd.msc)Solution: Reduce thread count
# Custom flags: /MT:4
# Or use robo-backup instead of robo-fast
Part of TheSecretJuice ๐ by mini-page
Need help? Open an issue