iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Robocopy is Windows’ command-line utility for copying files and directory trees. Use /E when you want every subfolder, including empty folders, copied to another location. Use /MIR only when the destination must become an exact mirror of the source, because it also deletes destination files and folders that are not present in the source. The safest workflow is to preview any important command with /L, verify both paths and the proposed changes, then run the command without /L.
What “sync” means in Robocopy
Robocopy does not provide a graphical two-way synchronization database. It compares a source tree with a destination and performs the copy operation described by your switches. In a normal one-way workflow, the source is authoritative: newer or missing source items are copied to the destination, while destination-only items are either preserved or removed depending on the command.
That distinction matters because “sync” can mean two different outcomes:
- Add or update without deleting: copy the source tree while leaving unrelated files already in the destination. This is the safer choice when the destination contains its own material.
- Make the destination match the source: mirror the source, including deleting destination-only files and folders. This is appropriate for a deliberate replica, not for a destination that people edit independently.
Robocopy’s basic form is:
robocopy <source> <destination> [<file> [...]] [<options>]
Put quotation marks around paths containing spaces. For example, "C:Project Files" is a single path, whereas an unquoted path with spaces is parsed as separate arguments.
#1 Best Overall
- Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Choose the copy behavior before writing a command
Use /E for a non-purging tree copy
/E copies all subdirectories, including empty directories. It does not tell Robocopy to remove destination-only content. This makes it the usual starting point for a backup or an additive copy where the destination may contain files that must remain.
/S is similar but excludes empty subdirectories. If an empty folder is part of the intended structure, use /E instead.
Use /MIR only for an intentional mirror
/MIR means “mirror the directory tree.” Microsoft documents it as equivalent to /E plus /PURGE. The purge component deletes destination files and directories that do not exist in the source. A typo in either path, or choosing the wrong folder level, can therefore cause extensive deletions and recopies.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Do not treat /MIR as a stronger version of backup. It is a synchronization policy with destructive behavior. If the destination is a shared folder, an external disk containing unrelated work, or a location where users make independent changes, start with /E and preserve destination-only items.
Prepare the source and destination safely
- Identify the exact source folder. Decide whether you mean a parent folder such as
C:UsersAlexDocumentsor one of its child folders. Robocopy copies the tree represented by the path you enter; moving the path one level up or down changes the result. - Identify the exact destination folder. Create or select the intended target before testing. For a removable drive, confirm its current drive letter in File Explorer because Windows can assign a different letter after reconnecting it.
- Check available space and access. The account running the command needs to read the source and write to the destination. Protected folders, disconnected shares, or insufficient destination space can produce failures that retries cannot fix.
- Decide whether destination-only files are valuable. If they must remain, use a non-purging command such as
/E. If they must be removed so the trees match, use/MIRonly after previewing it. - Create a log location. A folder such as
C:Logsmust already exist, or you should choose a path whose parent is available. Logging gives you a record to inspect after the run.
Preview every important operation with /L
/L is Robocopy’s list-only mode. Microsoft defines it as listing files without copying, deleting, or time-stamping them. It is the practical safety checkpoint for a first run and for every mirror whose paths or scope have changed.
To preview a mirror:
robocopy "C:Source" "D:Destination" /MIR /L
Read the output as a proposed change list. Confirm that:
- the source path is the folder you intended to publish or back up;
- the destination path is the correct disk, share, and folder level;
- files you expect to copy appear in the list;
- destination-only files shown for removal are genuinely disposable; and
- an unexpectedly broad set of folders is not caused by selecting a parent directory by mistake.
When the preview is correct, remove /L and run the same command. Do not change the source, destination, or other switches between preview and execution unless you perform another preview.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Copy a complete folder tree without purging the destination
This example copies every source subdirectory, including empty ones, and sets explicit retry and wait values. It also writes a log:
robocopy "C:Source" "D:Destination" /E /R:2 /W:5 /LOG:"C:Logsrobocopy.log"
Replace the paths with your own. The command’s choices are:
| Part | Purpose |
|---|---|
"C:Source" |
The authoritative folder tree being read. |
"D:Destination" |
The folder receiving missing or changed source items. |
/E |
Includes all subdirectories, even empty ones. |
/R:2 |
Retries a failed copy twice. |
/W:5 |
Waits five seconds between retries. |
/LOG:"C:Logsrobocopy.log" |
Writes the operation’s output to the specified log file. |
This operation does not request purge behavior, so files that exist only in the destination are not targeted for deletion by the command. You should still preview a new path arrangement with /L if the data is important.
Mirror a folder after checking the deletion list
Use a two-command sequence when the destination must match the source.
Recommended Free Tools
Step 1: preview
robocopy "C:Source" "D:Destination" /MIR /L
Step 2: execute the approved mirror
robocopy "C:Source" "D:Destination" /MIR /R:2 /W:5 /LOG:"C:Logsrobocopy.log"
The second command can delete destination-only files and folders. Treat the first command’s output as an approval checklist, not as optional information. If the preview shows an entire unrelated directory being removed, stop and correct the paths rather than running the mirror.
Microsoft’s Azure migration guidance warns that mismatched folder structures can lead to large-scale deletions and recopies. That warning also applies to ordinary local-drive use: a source ending in Documents and a destination aimed at the root of a disk do not describe equivalent folder levels.
Understand what metadata is copied
Robocopy’s documented default file-copy setting is /COPY:DAT. It copies:
Rank #3
- High capacity in a small enclosure – The small, lightweight design offers up to 6TB* capacity, making WD Elements portable hard drives the ideal companion for consumers on the go.
- Plug-and-play expandability
- Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
- SuperSpeed USB 3.2 Gen 1 (5Gbps)
- D — data: the file contents;
- A — attributes: file attributes such as read-only status; and
- T — timestamps: the file time information handled by the copy operation.
Security descriptors, owner information, and auditing data are separate concerns. The default /COPY:DAT does not by itself promise that those security elements will be replicated. If your migration requires permissions or ownership to be preserved, select the additional copy flags that match that requirement and test them with the account and file systems involved. Do not assume that a byte-for-byte content copy also reproduces access control.
Metadata requirements should be decided before the first large run. A personal document copy may need only data, attributes, and timestamps. A server migration may additionally require security information and an account with sufficient privileges. The command should reflect the actual requirement rather than adding every available flag automatically.
Set retries and waits deliberately
Robocopy exposes retry controls through /R:<n> and /W:<n>. Microsoft documents defaults of 1,000,000 retries and a 30-second wait between retries. Those defaults can make an interactive command appear to hang for a very long time when a file is locked, a network share is unavailable, or a device has been disconnected.
For a local test, a short explicit policy such as /R:2 /W:5 makes failures visible quickly. For an unreliable network, you may choose larger values, but make that choice consciously and record it in the command or log. A retry cannot repair a wrong path, a revoked permission, a full destination, or a permanently disconnected share.
Use logs to review a completed run
/LOG:<path> writes output to a log file. Microsoft also documents /LOG+:<path> for appending to an existing log rather than replacing it.
robocopy "C:Source" "D:Destination" /E /R:2 /W:5 /LOG:"C:Logsrobocopy.log"
Afterward, open the log and look for files that could not be copied, repeated retry messages, access errors, or a scope that is much larger than expected. Keep logs where they are not themselves inside a directory being mirrored and purged; otherwise a later operation could remove or replace the record you need.
Choose multithreading and restartable mode based on the workload
Multithreaded copying with /MT
/MT:<n> enables multithreaded copying. Microsoft documents a supported range of 1 to 128 threads and a documented default of 8 when multithreading is used. More threads are not automatically better: the useful value depends on the storage, network, file sizes, and competing workloads.
Rank #4
- Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Begin with a modest value, observe the result, and avoid changing several performance-related settings at once. Microsoft documents that /MT is incompatible with some options, including /IPG and /EFSRAW. If a command depends on one of those options, do not add /MT without checking the compatibility requirements.
Restartable mode with /Z
/Z requests restartable mode, which is useful when a copy may be interrupted and resumed. Microsoft’s Azure migration guidance cautions that /Z and /ZB can reduce copy performance. Consider them reliability choices for interruption-prone transfers, not universal speed improvements.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesFor a stable local copy, a simple /E command may be sufficient. For a long transfer across an SMB connection that may drop, evaluate restartability against the performance cost and test with a representative folder before scheduling a large run.
Copy between SMB shares
Robocopy can operate between Windows SMB file shares as well as between local drive letters. Use UNC paths in the source and destination positions, for example:
robocopy "\ServerAShareATeam" "\ServerBShareBTeam" /E /R:2 /W:5 /LOG:"C:Logsshare-copy.log"
The account running the command must be able to read the source share and write to the destination share. Test connectivity and permissions before starting a large transfer. A network interruption, expired credential, or unavailable server can cause retries without making progress, so explicit retry and wait values are particularly important here.
Microsoft’s Azure Files share-copy example uses the same general approach and notes that the command can be run again to copy changes made since the previous run. Re-running a non-purging command is useful when the source receives additional or updated files. If you intend to remove files that disappeared from the source, use the preview-first mirror workflow and verify the deletion list each time the folder structure changes.
Common mistakes and how to correct them
The destination is missing empty folders
Check whether the command used /S. Replace it with /E when empty directories are part of the required structure. Preview the revised command with /L before executing it.
Best Value
- World’s First 6TB 2.5” Portable Hard Drive
- Plug-and-play expandability
- Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
- SuperSpeed USB 3.2 Gen 1 (5Gbps)
Unexpected destination files are being deleted
The command probably includes /MIR, which includes purge behavior. Stop the run if the deletion is not intended. Use /E for an additive copy, or correct the source and destination paths and preview the mirror again.
The command appears stuck on one file
Robocopy may be applying its retry policy. The documented defaults are one million retries and 30 seconds between attempts, so an explicit /R and /W policy is essential for predictable interactive runs. Investigate file locks, disconnected storage, permissions, and network availability rather than waiting indefinitely.
Permissions did not come across
/COPY:DAT covers data, attributes, and timestamps, not every security property. Determine whether security descriptors, owner data, or auditing information are required, then choose the corresponding copy settings and run under an account authorized to read and apply them.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →A network copy is slower than expected
First verify that the path is reachable and that the operation is not repeatedly retrying failures. You can evaluate /MT:<n> for multithreaded copying, remembering that the supported range is 1 to 128 and that some options are incompatible with it. If you add /Z or /ZB for restartability, account for Microsoft’s warning that those modes can reduce performance.
The log is missing or incomplete
Check that the parent directory of the /LOG path exists and that the account can write there. Use /LOG+:<path> when you intentionally want to append to an existing file. Keep the log outside a mirrored tree if you need it to survive purge operations.
Practical command patterns
| Goal | Command | Important consequence |
|---|---|---|
| Copy all subdirectories, including empty ones | robocopy "C:Source" "D:Destination" /E /R:2 /W:5 |
Destination-only items are not intentionally purged. |
| Preview an exact mirror | robocopy "C:Source" "D:Destination" /MIR /L |
Lists proposed copies and deletions without changing files. |
| Run the approved mirror and log it | robocopy "C:Source" "D:Destination" /MIR /R:2 /W:5 /LOG:"C:Logsrobocopy.log" |
Deletes destination-only files and folders. |
| Use multithreading | robocopy "C:Source" "D:Destination" /E /MT:8 |
Uses eight threads; check option compatibility first. |
| Copy an SMB share tree | robocopy "\ServerAShareATeam" "\ServerBShareBTeam" /E /R:2 /W:5 |
Requires working read and write access to both shares. |
A repeatable operating checklist
- Confirm the source and destination character by character, including drive letters, share names, and folder levels.
- Choose
/Ewhen destination-only content should remain; reserve/MIRfor an intentional source-authoritative replica. - Use
/E, not/S, when empty directories must be included. - Preview a new or destructive command with
/L. - Set
/Rand/Wvalues that fit the environment instead of relying on the documented defaults of 1,000,000 retries and 30 seconds. - Decide whether the default
/COPY:DATfidelity is enough or whether security, owner, or auditing data must also be handled. - Add
/LOGor/LOG+when you need an auditable record, and store the log outside a purged tree. - Evaluate
/MTfor throughput and/Zfor restartability separately; neither is a universal improvement. - After execution, inspect the log and investigate errors instead of assuming that a completed command means every item succeeded.
How to decide between the main options
| Requirement | Prefer | Reason |
|---|---|---|
| Keep files that exist only at the destination | /E |
Copies the source tree without requesting purge behavior. |
| Remove destination-only files so both trees match | /MIR, after /L |
Combines /E with /PURGE; deletion is intentional and reviewed. |
| Include empty directories | /E |
Includes empty subdirectories. |
| Exclude empty directories | /S |
Copies subdirectories but leaves empty ones out. |
| Preserve ordinary file content and basic metadata | /COPY:DAT (documented default) |
Covers data, attributes, and timestamps. |
| Recover more gracefully from interruptions | /Z, when appropriate |
Restartable mode can help interrupted transfers but may reduce performance. |
| Increase concurrent copy work | /MT:<n> |
Supports 1–128 threads; verify incompatibilities with other switches. |
Bottom line for a safe first run
For most first-time local copies, start with robocopy "source" "destination" /E /R:2 /W:5, using real quoted paths and adding a log when you need a record. If the goal is an exact replica, preview /MIR /L, inspect every proposed deletion, and only then remove /L. That preview-and-verify habit is the key difference between a controlled Robocopy sync and an accidental purge.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

