Robocopy is a powerful, robust, and Windows-native command-line tool for copying files, folders, and even syncing directories — especially useful for backup, migration, or bulk copying.
✅ Robocopy Basics
robocopy [source] [destination] [/options]
🎯 Example: Copy a Folder and All Its Files
✅ Basic Copy (with subfolders)
robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5
🔍 Breakdown of Options
| Option | Description |
|---|---|
/E | Copy subdirectories and empty directories too. |
/COPY:DAT | Copy data, attributes, and timestamps — preserves file metadata. |
/R:10 | Retry up to 10 times if a file fails to copy. |
/W:5 | Wait 5 seconds between retries. |
/LOG+:C:\backup.log | Log output to a file — useful for debugging or tracking. |
/Z | Copy files even if they’re open (useful for files being used by programs). |
🧩 Example: Copy with Logging
robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5 /LOG+:C:\backup.log
This logs the copy operation to
C:\backup.log.
📌 Example: Copy Without Overwriting
robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5 /Z /COPY:DAT
This copies files without overwriting — if a file already exists, it will not overwrite it.
📂 Example: Copy with Overwrite (Default)
robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5
This copies all files — and overwrites existing files.
🧠 Pro Tips
- Use
/LOG+:C:\backup.logto track what’s copied — very useful for debugging. - Use
/Zif you’re copying files that are being used (e.g., by a program). - Use
/COPY:DATto preserve file metadata (timestamps, permissions, etc.). - Use
/Eto copy empty directories too.
📄 Example: Copy a Folder with Logging
robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5 /LOG+:C:\backup.log
🚫 Common Mistakes
- ❌
robocopy C:\Folder D:\Folder— Wrong! You must specify the folder name. - ❌
robocopy C:\Folder\ D:\Folder\ /E— Wrong! You need to specify the folder name. - ❌
robocopy C:\Folder\ D:\Folder\ /E /I— Wrong! You need to specify the folder name.
✅ Correct: `robocopy “C:\Folder” “D:\
I hope this helps you as much as it has helped me with my Windows backups.
