Command referencerobocopy
robocopy command (Windows / CMD)
What it does
Reliably copy and synchronize large directory trees. Searches for the robocopy command cmd usually need CMD syntax, practical switches, and notes on how it compares with PowerShell or Linux alternatives. This page covers syntax, common options, and copyable examples for Command Prompt.
Reliably copy and synchronize large directory trees.
Syntax
robocopy source destination [file ...] [options]
Common options
| Flag / option | Meaning |
|---|---|
| /E | Copy subdirectories, including empty ones. |
| /MIR | Mirror the source tree into the destination. |
| /Z | Use restartable mode. |
| /R:n | Set retry count. |
| /LOG:file | Write output to a log file. |
Practical examples
Copy tree
robocopy C:\Data D:\Backup /E
Copies all subdirectories, including empty ones.
Restartable copy
robocopy \\server\share D:\Share /E /Z /R:3
Copies a network tree with bounded retries.
Logged mirror
robocopy C:\Site D:\SiteMirror /MIR /LOG:mirror.log
Mirrors a tree and records results.
Linux ↔ Windows equivalent
Closest match: cp (Linux / bash / sh / zsh). Copy files or directory trees to another location.
Common mistakes
- Danger: `/MIR` deletes destination entries absent from the source; verify both paths first.
- Treating robocopy success codes above zero as failures; several indicate successful differences.
- Omitting retry limits and waiting through very large defaults.
Related commands
- xcopyCopy files and directory trees with filtering and overwrite controls.
- copyCopy one or more files and optionally combine text or binary files.
- Copy-ItemCopy items between locations supported by PowerShell providers.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- findWalk directory trees and select entries using tests and actions.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
FAQ
What does robocopy do in Command Prompt?
Reliably copy and synchronize large directory trees.
How do I run robocopy in CMD?
Open Command Prompt and follow `robocopy source destination [file ...] [options]`; quote paths containing spaces.
What is a practical robocopy example in CMD?
Try `robocopy C:\Data D:\Backup /E` — Copies all subdirectories, including empty ones.
Can robocopy be used in a batch file?
Yes. Check its exit code and escape CMD metacharacters when input is variable.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.