ROBOCOPY vs XCOPY: which one to use

XCOPY has been part of Windows since DOS. Robocopy shipped with Windows Server 2003 Resource Kit and became a standard OS component in Vista. For most file copy tasks today, Robocopy is the right choice — but XCOPY is still present on every Windows machine, it is simpler for short one-off operations, and some scripts still rely on it. Knowing what each tool can and cannot do tells you when to use which.

This is not a theoretical comparison. The differences that matter in practice are retry behavior, permission handling, logging, and what happens when a copy fails halfway through.


Side-by-side comparison

FeatureXCOPYRobocopy
Copy subdirectoriesYes — /S, /EYes — /S, /E
Mirror (delete extras)NoYes — /MIR
Retry on failureNoYes — /R:N /W:N
Restartable modeNoYes — /Z
Multi-threaded copyNoYes — /MT:N
Preserve ACLsPartial — /OFull — /COPYALL
Preserve timestampsYes — /KYes — included in /COPY:T
Exclude files by patternPartial — /EXCLUDEFull — /XF, /XD, /XA
Log to fileNo built-in loggingYes — /LOG, /TEE
Exit code system0 = success, 1–5 = errorsBitmask — 0–7 informational, 8+ errors
Copy open files (VSS)NoNo
Available onAll Windows versionsVista and later, Server 2003 R2+

When XCOPY is still acceptable

XCOPY makes sense in a narrow set of situations where its simplicity is an advantage rather than a limitation.

Short one-off copies in an interactive session. If you need to copy a folder right now, from the command line, without writing a script — XCOPY is faster to type. No flags to remember beyond /E for subdirectories and /Y to suppress confirmation prompts.

rem Quick one-off copy — all subdirectories, no confirmation prompt
xcopy C:\Source D:\Destination /E /Y

Legacy batch scripts you are not ready to rewrite. If an existing script uses XCOPY and works reliably for its purpose, changing it to Robocopy introduces risk without clear gain. Leave it until the script needs maintenance anyway.

Environments where Robocopy is not available. Windows XP and early Server 2003 without the Resource Kit do not have Robocopy. In practice this is rare, but XCOPY remains the fallback on those systems.

Warning: XCOPY does not retry on failure. If a file is locked by another process or a network glitch interrupts the copy, XCOPY stops or skips the file with no recovery. For any copy that matters — migrations, backups, scheduled jobs — use Robocopy.

When Robocopy is the only right answer

Any unattended or scheduled copy. XCOPY has no retry logic. One locked file or one network hiccup and the job silently fails or produces an incomplete result with no log to show what happened. Robocopy retries, logs, and exits with a code you can check.

Copying with NTFS permission preservation. XCOPY’s /O flag copies ownership and ACL information, but it is incomplete compared to Robocopy’s /COPYALL. For server migrations where permissions must survive exactly, Robocopy is the only reliable option.

Mirror operations. XCOPY has no equivalent to /MIR. You cannot use it to keep a destination in sync with a source while also removing files that have been deleted from the source. This is Robocopy-only territory.

Large file counts or slow network paths. XCOPY copies one file at a time with no resume capability. Robocopy’s /MT parallelizes the copy, and /Z restarts interrupted transfers at the point of failure rather than from the beginning of the file.

Any copy that needs a log. XCOPY writes to stdout only. If you redirect output to a file you lose console feedback. Robocopy’s /LOG and /TEE write to a file and the console simultaneously, with a structured summary at the end.


Flag equivalents

If you are converting an existing XCOPY command to Robocopy, this mapping covers the most common flags:

XCOPY flagWhat it doesRobocopy equivalent
/SCopy subdirectories (not empty)/S
/ECopy subdirectories including empty/E
/YSuppress overwrite confirmationDefault behavior — no flag needed
/HCopy hidden and system files/A-:SH or /IA:SH
/KPreserve file attributes/COPY:DAT
/OCopy ownership and ACLs/COPY:DATSOU or /COPYALL
/D:dateCopy only files changed after date/MAXAGE:N
/EXCLUDE:fileExclude files listed in a text file/XF pattern, /XD folder

Example conversion — XCOPY to Robocopy:

rem Original XCOPY command
xcopy C:\Source D:\Destination /E /K /H /Y

rem Robocopy equivalent — same intent, with retry and logging added
rem /E        — copy all subdirectories including empty ones
rem /COPY:DAT — preserve data, attributes, timestamps (equivalent to /K)
rem /A-:SH    — include hidden and system files (equivalent to /H)
rem /R:3 /W:5 — retry behavior (no XCOPY equivalent)
rem /LOG+:    — log output (no XCOPY equivalent)

robocopy C:\Source D:\Destination /E /COPY:DAT /A-:SH /R:3 /W:5 /LOG+:C:\bat\copy-log.txt

Exit code differences

XCOPY and Robocopy use completely different exit code systems. If you are converting a script, the error handling logic must change too.

Exit codeXCOPY meaningRobocopy meaning
0Files copied successfullyNo files copied — source and destination identical
1No files found to copyFiles copied successfully
2User pressed Ctrl+CExtra files in destination (informational)
4Initialization errorMismatched files (informational)
5Disk write error
8Copy failures occurred (first real error code)
Common mistake: Replacing XCOPY with Robocopy in a script without updating the exit code check. XCOPY returns 0 on success — so scripts typically check IF %ERRORLEVEL% NEQ 0. Robocopy returns 1 on a successful copy, which triggers that same error branch. After converting to Robocopy, change all exit code checks to IF %ERRORLEVEL% GEQ 8.

Official documentation

Related tools

Related guides