Skip to main content

Command referencerobocopy

robocopy command (Windows / CMD)

WindowsCMDfileintermediate

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 / optionMeaning
/ECopy subdirectories, including empty ones.
/MIRMirror the source tree into the destination.
/ZUse restartable mode.
/R:nSet retry count.
/LOG:fileWrite 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.

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.