keepcalculator

06 Numbers and Powers

Robocopy Commands: Full List and What They Do

Card No. 06·61508 · Updated · Standard formula, shown below

Robocopy has no single short command list that covers every Windows version: it is a command-line file-copy tool with a core syntax, many switches, and some options that vary by release. The reference below groups the commonly documented commands by purpose and explains how to check the options available on your own computer.

What Robocopy does

Robocopy, short for Robust File Copy, is included with Windows and copies files and directory trees from one location to another. It is designed for repeatable transfers: it can retry failed copies, preserve selected file attributes, mirror directory structures, and write a log. It is not a general-purpose backup system, and a successful copy does not by itself prove that the destination is a complete, restorable backup.

The basic form is:

robocopy source destination [file [file]...] [options]

For example, robocopy C:\Work D:\Work /E copies the contents of C:\Work, including subdirectories, to D:\Work. Run robocopy /? in Command Prompt or PowerShell to display the help supplied with your Windows installation. That local help is the best authority for switches supported by that version.

Core syntax and path rules

The source and destination are directory paths; optional file patterns restrict which files are considered. A wildcard such as *.txt selects matching files. Quote a path containing spaces, for example "C:\Project Files". In PowerShell, the external command is still robocopy; its switches use Robocopy’s own syntax rather than PowerShell parameter names.

Robocopy’s behavior depends heavily on the selected options. Without a recursion switch it copies files in the top-level source directory. A trailing backslash is generally not required to express the directory, but using clear, quoted paths helps avoid mistakes. Test the command first with /L, which lists what would happen without copying or deleting files.

Commonly used Robocopy switches

These are widely used switches, grouped by task. The full local help output includes additional combinations and details.

  • /S — copy subdirectories, but skip empty ones.
  • /E — copy subdirectories, including empty ones.
  • /LEV:n — limit recursion to a specified number of directory levels.
  • /Z — use restartable mode, allowing a file copy to resume after interruption in supported circumstances.
  • /B — use backup mode, which relies on backup privileges and is intended for particular access situations.
  • /ZB — try restartable mode, then use backup mode if access is denied.
  • /MT[:n] — copy using multiple threads; the thread count is optional. Check local help for supported limits.
  • /R:n — set the number of retries after failed copies.
  • /W:n — set the wait, in seconds, between retries.
  • /COPY:flags — choose which file information to copy. The default is commonly described as data, attributes, and timestamps; consult help for the flag letters and alternatives.
  • /DCOPY:flags — choose directory information to copy, such as attributes and timestamps; supported flags can differ by version.
  • /LOG:file — write output to a log file, replacing an existing log.
  • /LOG+:file — append output to an existing log.
  • /TEE — display output in the console as well as writing it to a log.
  • /L — list actions without performing them.
  • /NFL and /NDL — omit file names and directory names from output.
  • /NP — omit progress percentages from output.

Mirror, purge, and deletion options

Deletion-related switches deserve special attention because they can remove destination data. /MIR mirrors a directory tree: it is equivalent to copying subdirectories, including empty ones, and purging destination items that do not exist in the source. /PURGE likewise removes destination files and directories that are absent from the source, while copying the selected source content.

Do not treat /MIR as a harmless “copy everything” option. If the source path is wrong, incomplete, or temporarily unavailable, a mirror operation can make the destination match that mistaken state. A safer first check is to run the intended command with /L, inspect the proposed actions and paths, and only then remove /L if the plan is correct. Keep a separate backup when you need to retain older destination files.

Other switches affect what is eligible for copying. /XO excludes older source files, /XN excludes newer source files, and /XC excludes files whose timestamps match but whose contents may differ. /XX excludes extra destination files from the listing or operation; it does not mean “delete extras.” Interpret these in combination with the other options, not in isolation.

Example commands and choosing options

For a straightforward copy that includes all subdirectories, a useful starting point is:

robocopy "C:\Work" "D:\Work" /E /R:2 /W:2 /LOG:"C:\Logs\work-copy.txt"

This includes empty folders, retries failed copies twice, waits two seconds between retries, and writes a log. The values are examples, not universal recommendations; choose retry behavior and log location for the job.

To preview a mirror operation before making changes:

robocopy "C:\Work" "D:\Work" /MIR /L /LOG:"C:\Logs\mirror-preview.txt"

Review the log carefully. If the source and destination are reversed, or the source is not the intended complete tree, a real mirror can delete files from the destination.

Choose switches according to the requirement:

  • Use /E to copy a tree without deleting destination-only items.
  • Use /MIR only when the destination should be an exact mirror, including removals.
  • Use /MT for workloads that benefit from parallel copying, while considering system and storage load.
  • Use /Z when interruption is a concern, especially across a network; it does not guarantee every transfer can resume in every circumstance.
  • Use logs for long or unattended jobs, and check both the log and Robocopy’s exit code.

Exit codes and common problems

Robocopy exit codes are bit-coded status values, not ordinary “zero means success, anything else means failure” codes. A value of 1 commonly indicates that files were copied; other low values can indicate extra files or mismatches without a copy failure. Values of 8 or higher indicate at least one failure. Because multiple conditions can be combined, check the exit-code table in the local help and inspect the log rather than treating every nonzero result as an error.

Common issues include access denied, a typo in a path, unavailable network shares, files changing during the copy, and unexpectedly long retry waits. Check that the account running the command can read the source and write the destination. A drive letter mapped in an interactive session may not be available to a scheduled task, so use an appropriate accessible path and test under the same account and context. Robocopy also does not make open-file copying universally reliable; applications may need to be closed or a suitable snapshot-based backup approach used.

Frequently Asked Questions

How do I see the full Robocopy command list?
Run robocopy /? in Command Prompt or PowerShell. It displays the syntax, switches, and explanations available in the installed version.

Does Robocopy delete files?
Basic copying does not normally remove destination-only files. Options such as /MIR and /PURGE do remove destination items absent from the source, so preview and verify paths before running them.

What is the difference between /S and /E?
Both copy subdirectories. /S skips empty subdirectories; /E includes them.

Is Robocopy included with Windows?
Robocopy is included with modern Windows versions, but available options can vary. Use the help on the computer where the command will run.

Does Robocopy copy permissions?
Not necessarily. The default copy flags do not mean every security setting is copied. Review /COPY and /SEC or /COPYALL in local help, and make sure the account has the required permissions.

Can I use Robocopy to make a backup?
It can copy files to a second location, but a mirror can propagate deletions and changes. For recoverable backups, retain independent versions and verify that important files can be restored.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →