Copying Files Between Disks with XCOPY or Robocopy: A Complete Guide

Last update: 24/09/2025
Author Isaac
  • ROBOCOPY allows mirroring (/MIR), monitoring and programming; XCOPY covers simple bulk copies.
  • Incremental copies with XCOPY (/D, /U) and ROBOCOPY (/XO, /MAXAGE, /XL) according to policy.
  • Advanced options in ROBOCOPY: multithreading, retries, logs, security NTFS and fine filters.
  • Graphical alternatives (AOMEI/EaseUS) to sync, backup and restore without a console.

Copy files with xcopy and robocopy

If you work with Windows, sooner or later you will need move large volumes of data between disks or serversIn that scenario, commands XCOPY and ROBOCOPY are two Swiss Army knives Essential: fast, flexible, and designed to automate everything from one-off backups to scheduled synchronizations.

In the following lines you will find a practical and very complete guide to understand what each tool does, When is it best to use one or the other, and how to get the most out of them with the right switches? For real-world use cases: clone folder structures, copy only new or modified files, schedule copy windows, monitor changes, generate logs, and much more.

What are XCOPY and ROBOCOPY in Windows?

XCOPY and ROBOCOPY are command-line utilities built into Windows that are used to copy files and directories. XCOPY focuses on copying multiple files or entire trees (including network), with more advanced features than COPY. ROBOCOPY (Robust File Copy) goes one step further: It is a robust replication engine with dozens of parameters all with synchronize, mirror, retry on errors and log everything.

Key differences between XCOPY and ROBOCOPY

The big functional difference is mirroring: ROBOCOPY can “mirror” (/MIR) a directory tree, eliminating at the destination what no longer exists at the source; XCOPY does not mirror as such.

In automation, ROBOCOPY stands out with /RH (Run Hours) to set time slots execution, something that XCOPY doesn't offer natively. This allows jobs to be launched during off-peak hours without depending on the timing of the command.

In monitoring, ROBOCOPY incorporates /MON:n and /MOT:m to monitor changes: replicates after n modifications or every m minutes if it detects new changes. XCOPY does not have an equivalent listening mode.

In attributes, both deal with the Archive attribute, but ROBOCOPY copies more metadata (security, owner, audit, timestamps) with /COPY and /DCOPY. This is key in NTFS environments with fine-grained permissions.

Limitations and Important Considerations

Neither XCOPY nor ROBOCOPY are magic with files in use: Open files usually give blocking problems, unless you use snapshot services or alternatives that support VSS. Keep this in mind on production systems.

XCOPY doesn't show detailed progress and can be spartan; It is not the ideal option for backing up OS volumes “hot”. On the other hand, ROBOCOPY does offer more verbosity and useful exit codes.

Regarding compatibility, non-ideal mirroring behavior in ROBOCOPY was reported on systems prior to Windows Vista; On modern versions of Windows it works as expected. Also remember the FAT temporal granularity: With /FFT we assume 2 second precision.

How to use XCOPY step by step

The general form is XCOPY source destination As an example, to copy a folder with all its contents, including hidden and empty subfolders, and continue on errors, you can use:

XCOPY C:\test D:\test /E /H /C /I

Meaning of these switches: /E (subdirectories, including empty ones), /H (hidden and system files), /C (continue even if there are errors) and /I (if in doubt, assume a destination as a directory). They are the basics for mass copies without silly interruptions.

  News: Windows 10 slider can select anything

Golden tip: if there are spaces on routes, wrap them in quotation marks, for example "D:\Mis Datos". You will avoid errors caused by shell parsing.

How to use Robocopy step by step

The base syntax is ROBOCOPY source destination . To copy specific files from one folder to another, a simple example would be:

robocopy E:\backuptest F:\backuptest1 a-test.docx b-test.txt

To make “smart” copies you can add /XO (exclude older) or / MIR (mirror, equivalent to /E + /PURGE). These are two common modes of incremental/synchronization according to the desired policy.

Real-life example combining multithreading and network outage resumption: improves performance and resilience to /MT y /Z copying to a share:

robocopy C:\reports \\marketing\videos yearly-report.mov /mt /z

And don't forget to register: keep a log to audit and verify later. For example: /LOG:C:\Logs\Backup.log or in Unicode with /UNILOG.

Copy only new or modified files

There are two classic approaches: XCOPY with /D and variants, and Robocopy with date/age or exclusion filters. Choose whether you want to allow new files in the destination or only update existing ones.

With XCOPY, the relevant syntax is /D. Undated, copy whatever is newer than the destination. You can combine with /U to copy only files that already exist on the destination (does not create new ones), /S for subfolders and /Y to avoid asking when overwriting.

Typical scenarios with XCOPY (adjust paths and use quotes if necessary): They range from updating only existing ones to also bringing in new directories..

  • Update the latest (you can create new ones if they don't exist): xcopy "D:\Source" "K:\Target" /S /D
  • Update without creating new directories: xcopy "D:\Source" "K:\Target" /I /D /Y
  • Update only if it already exists at the destination: xcopy "D:\Source" "K:\Target" /S /D /U
  • Bring new directories too: xcopy "D:\Source\copy files" "K:\Target\files copiados" /I /D /Y /E

With ROBOCOPY, two techniques are common: filter by age with /MAXAGE:n (n days) and/or exclude older ones with /XO. To avoid empty directories, add /S. This is how you achieve simple incrementals without complications.

  • Copy the newest or added: robocopy D:\folder1 E:\folder2 /MAXAGE:7 o robocopy D:\folder1 E:\folder2 /XO /MAXAGE:7
  • No empty folders: add /S to any of the above

Very specific case? Maybe you want copy only those that have changed, but do not create new ones (as requested by an administrator to compare configuration changes). With ROBOCOPY you can use /XL to exclude “lonely” files (present at the source but not at the destination) and let it copy only the ones that differ: robocopy "C:\Origen" "D:\Destino" /S /XL. This is how existing mods are updated and no new files are added.

Mirroring and synchronization: /MIR, /PURGE and precautions

ROBOCOPY's mirror mode, /MIR, replicates and also deletes at destination whatever is missing from the source (equivalent to /E + /PURGE). Useful for clean deployments, but dangerous if you aim incorrectly: If you choose the wrong destination, you can delete the data. that you didn't want to touch.

If you are just looking to clean up leftover files, /PURGE enough; /MIR also secures the entire structure (including empty ones). Choose the couple that best fits with your synchronization policy.

Copy only the folder structure with XCOPY

When you need to replicate the hierarchy without the files, XCOPY solves it with /T (structure only) and /E (includes empty subfolders). Ideal for preparing scaffolding in new environments.

Example: XCOPY "C:\Users\Default\Carpeta de pruebas" "D:\Pruebas" /T /E. The first route is the source whose structure you want to clone; the second, the destination where you will create that same hierarchy.

  Danger! OneDrive becomes the default location in Office: what's changing and how to revert it

Four ways to make copies from CMD

Those who prefer consoles can cover almost any need with these options. Choose based on whether they are individual files, structures, or if you need a system image.:

  • 1) ROBOCOPY: Recommended command for large, robust backups, with over 80 parameters and switches. Ideal for large network sharing. automatic retries and detailed logs.
  • 2) XCOPY: Classic line for files and directories with useful switches like /D, /E, /H, /C. Simple and sufficient for many basic batches.
  • 3) Notepad: in recovery environments, launch notepad.exe from CMD, use File > Save As to navigate and copy to USB with “Send to”. Useful trick when the system won't boot and you want to save files without struggling with commands.
  • 4) EaseUS Todo Backup (CLI): for partitions, disks and system, your command etbcmd allow Full, differential and incremental backups, even to network routes, and also has a GUI.

AOMEI Backupper: A graphical alternative for synchronizing and backing up

If you prefer a graphical interface and advanced options without memorizing switches, AOMEI Backupper is a very complete alternative to XCOPY/ROBOCOPY for synchronization and backup.

Among its functions are: sync with USB, NAS, network or cloud; one-way, two-way, mirror, and real-time synchronization (the last three in paid editions); automatic programming and the ability to copy open files without blocking work.

Basic Sync Quick Start Guide: Install and open, go to Sync > Basic Sync, choose source folders, choose the destination (external disk, network, cloud...), and schedule if you want daily, weekly or monthlyYou can add notes and activate email notifications.

It also allows file backup (image compression), recovery and cloning, and other utilities. If you use their cloud, after registration they offer 1 TB trial for 15 days for cloud backup.

Robocopy in depth: well-organized main options

To get the most out of it, here are the most relevant parameter categories. All are also consulted with “robocopy /?” in CMD in case you want to expand on the details.

Copy options

  • /S: subdirectories (excludes empty ones). /E: empty included subdirectories.
  • /Z: Rebootable mode. /B: backup mode. /ZB: Restartable and if it fails, it goes to backup.
  • /J: Unbuffered I/O (recommended for large files). /EFSRAW: copies encrypted files in raw mode.
  • /COPY:: which properties to copy (data, attributes, times, ACL, owner, audit; default DAT).
  • /DCOPY:: what to copy into directories (default DA).
  • /SEC (= /COPY:DATS), /COPYALL (= DATSOU), /NOCOPY (useful with /PURGE), /SECFIX, /TIMFIX.
  • /PURGE: deletes at the destination what is missing at the source. / MIR: mirror (= /E + /PURGE).
  • /MOV: moves files. /MOVE: moves files and directories.
  • /A+: y /TO-:: add or remove attributes when copying.
  • /CREATE: creates zero-length tree and files. /FAT: names 8.3. /256: : disable routes > 256.
  • /MON:n, /MOT:m: monitor changes. /RH:hhmm-hhmm: time window. /PF: check by file.
  • /IPG:n: space out packets (slow lines). /SJ//SL: behavior with symbolic links.
  • /MT:n: multithreaded (1–128, default 8). Not compatible with /IPG or /EFSRAW. Greatly improves performance.
  • /NODCOPY, /NOOFFLOAD, /COMPRESS, /SPARSE:y|n, /NOCLONE: Advanced copy settings.
  • /IOMAXSIZE, /IORATE, /THRESHOLD: I/O and bandwidth limitation (minimum 524.288 bytes/s).
  Kindle Paperwhite Vs Voyage Comparability | Which One to Purchase?

File selection

  • /A: only with File attribute. /M: File and clean it after copying.
  • /IA: e /FOR:: include/exclude by attributes.
  • /XF Names, /XD directories: exclude by pattern (wildcards * and ?).
  • /XC: excludes same timestamp but different size. /XN: excludes newer ones at destination. /XO: excludes older ones.
  • /XX: excludes extra at destination (does not delete). /XL: excludes “solitary” (only in origin).
  • / IM: include modified (change times). /ES: include equals. / IT: include “retouched” (attributes).
  • /MAX:n, /MIN:n: size limits. /MAXAGE:n, /MINAGE:n: limits by age or date.
  • /MAXLAD, /MINLAD: last accesses (if n < 1900, it is days; otherwise, YYYYMMDD).
  • /XJ, /XJD, /XJF: exclude join points. /FFT: FAT times (2 s). /DST: adjust daylight saving time.

Retries

  • /R:n: retries (default 1.000.000). /W:n: wait between retries (default 30 s). /REG: save as default.
  • /TBD: wait for shared names to be defined (error 67). /LFSM: Low space mode, pause and resume based on the volume “floor”.

Logging

  • /L: only list (does not copy/delete/date). /V: detailed output. /TS: timestamps. /FP: complete routes. /BYTES: sizes in bytes.
  • /NS, /NC, /NFL, /NDL, /NP: adjust verbosity (no sizes, classes, names, progress…). /REMOTE: estimated time.
  • /LOG:file, /LOG+:file, /UNILOG:file, /UNILOG+:file, /TEE, /NJH, /NJS, /UNICODE: full control of the log.

Jobs

  • /JOB:name, /SAVE:name: save/load parameters of a “job”. /QUIT: exit after processing line (see parameters).
  • /NOSD//NODD: no origin/destination. /IF: include specified files.

Official additional notes: /MIR and /PURGE no longer touch System Volume Information in roots; “modified sorting” requires file systems that support change times; /DCOPY:E attempts to copy extended attributes into directories; throttling parameters may be adjusted and the system may enforce valid limits; /LFSM sets the floor to 10% of the volume if you don't give a value and it is incompatible with /MT and /EFSRAW.

Exit codes

  • 0: no files copied, no errors.
  • 1: : all copied correctly.
  • 2: There are extra files at the destination, they were not copied.
  • 3: some copied, there was extra, no mistakes.
  • 5: some copied, others did not match, no errors.
  • 6: extra and non-matching; not copied, no errors.
  • 7: something was copied, there were matching errors and extra.
  • 8: : several files were not copied.

useful examples

  • Copy all (including empty) with reboot and log: robocopy C:\Users\Admin\Records D:\Backup /E /ZB /LOG:C:\Logs\Backup.log
  • Mirror with few retries and short wait: robocopy C:\Users\Admin\Records D:\Backup /MIR /R:2 /W:5 /LOG:C:\Logs\Backup.log
  • Copy subfolders and keep DAT with 16 threads: robocopy C:\Users\Admin\Records D:\Backup /S /E /COPY:DAT /MT:16 /LOG:C:\Logs\Backup.log
  • Move excluding the above to 7 days: robocopy C:\Users\Admin\Records D:\Backup /S /MAXAGE:7 /MOV /LOG:C:\Logs\Backup.log
  • With ETA and cleaning of leftovers: robocopy C:\Users\Admin\Records D:\Backup /ETA /PURGE /LOG:C:\Logs\Backup.log
  • Limit I/O to 1 MB/s: robocopy C:\Records D:\Backup /iorate:1m
  • Do not copy anything if it already exists (regardless of the date): robocopy C:\Source C:\Destination /XC /XN /XO
robocopy
Related article:
Robocopy: Tutorial on the Command to Copy and Sync Files