- 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.
If you work with Windows , sooner or later you'll need to move large volumes of data between disks or servers . In that scenario, the XCOPY and ROBOCOPY commands are two indispensable Swiss Army knives: 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 understanding what each tool does, when it is convenient to use one or the other, and how to get the most out of them with the appropriate switches for real cases: cloning folder structures, copying only new or modified files, scheduling copy windows, monitoring changes, generating logs and much more.
What are XCOPY and ROBOCOPY in Windows?
XCOPY and ROBOCOPY are command-line utilities built into Windows for copying files and directories. XCOPY focuses on copying multiple files or entire trees (including network files), with more advanced features than COPY. ROBOCOPY (Robust File Copy) goes a step further: it's a robust replication engine with dozens of parameters for synchronizing , mirroring, retrying on failures, and logging everything.
Key differences between XCOPY and ROBOCOPY
The main functional difference is mirroring: ROBOCOPY can "mirror" (/MIR) a directory tree , removing in the destination what no longer exists in the source; XCOPY does not mirror as such.
In automation, ROBOCOPY stands out with /RH (Run Hours) for setting execution time slots, something XCOPY doesn't offer natively. This allows you to run jobs outside of peak hours without depending on the command's timing.
In monitoring, ROBOCOPY incorporates /MON:ny /MOT:m to monitor changes : it replicates after n modifications or every m minutes if it detects new changes. XCOPY does not have an equivalent listening mode.
In terms of attributes, both handle the Archive attribute, but ROBOCOPY copies more metadata (security, owner, auditing, timestamps) with /COPY and /DCOPY. This is key in NTFS environments with granular permissions.
Limitations and Important Considerations
Neither XCOPY nor ROBOCOPY are magic when dealing with files in use: open files often cause locking issues unless you use snapshot services or alternatives that support VSS. Keep this in mind for production systems.
XCOPY doesn't show detailed progress and can feel spartan; it's not the ideal choice for hot-swapping OS volume backups . ROBOCOPY, on the other hand, offers more verbosity and useful exit codes.
Regarding compatibility, on systems prior to Windows Vista, non-ideal mirroring behavior was reported in ROBOCOPY; on modern versions of Windows, it works as expected . Also, remember the FAT temporal granularity : with /FFT, we assume 2-second accuracy.
How to use XCOPY step by step
The general format is XCOPY source destination . As an example, to copy a folder with all its contents, including hidden files and empty subfolders, and continue in case of errors, you can use:
XCOPY C:\test D:\test /E /H /C /I
Meaning of those switches: /E (subdirectories, including empty ones), /H (hidden and system files), /C (continue even if errors occur), and /I (if in doubt, assume destination directory). These are the basics for mass copies without unnecessary interruptions.
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 basic 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 create "smart" backups, you can add /XO (exclude older files) or /MIR (mirror, equivalent to /E + /PURGE). These are two common incremental/synchronization modes depending on the desired policy.
Real-life example combining multithreading and network outage resumption: improves performance and resilience with /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 filters or exclusions . Choose depending on whether you want to allow new files in the destination or only update existing ones.
With XCOPY, the relevant syntax is /D . Without a date, it copies anything newer than the destination. You can combine it with /U to copy only files that already exist in the destination (it doesn't create new ones), /S for subfolders, and /Y to not prompt when overwriting.
Typical scenarios with XCOPY (adjust paths and use quotes if appropriate): cover everything 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: filtering by age with /MAXAGE:n (n days) and/or excluding older files with /XO . To avoid empty directories, add /S . This allows for simple incremental backups without complications.
- Copy the newest or added:
robocopy D:\folder1 E:\folder2 /MAXAGE:7orobocopy D:\folder1 E:\folder2 /XO /MAXAGE:7 - No empty folders: add
/Sto 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 the destination what is missing from the source (equivalent to /E + /PURGE). Useful for clean deployments, but "dangerous" if you aim incorrectly: if you select the wrong destination, you can delete data you didn't intend to touch.
If you're only looking to clean up leftover files, /PURGE is sufficient; /MIR also ensures the complete structure (including empty ones). Choose the pair that best fits your synchronization policy.
Copy only the folder structure with XCOPY
When you need to replicate the hierarchy without the files, XCOPY solves this with /T (structure only) and /E (includes empty subfolders). It's ideal for 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.
Four ways to make copies from CMD
Those who prefer the console can cover almost any need with these options. Choose based on whether you need individual files, structures, or 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.exefrom 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
etbcmdallow 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 synchronizing and backing up.
Its features include: synchronization with USB, NAS, network or cloud ; one-way, two-way, mirror and real-time synchronization (the latter three in paid editions); automatic scheduling and the ability to copy open files without blocking work.
Quick guide to basic synchronization: Install and open, go to Sync > Basic Sync , choose source folders, select the destination (external drive, network, cloud…), and schedule whether you want daily, weekly, or monthly synchronization. You can add notes and enable email notifications.
It also allows file backup (compressing into an image), recovery, cloning, and other utilities. If you use their cloud service, after registration they offer a 1 TB trial for 15 days for cloud backups.
Robocopy in depth: well-organized main options
To get the most out of it, here are the most relevant parameter categories. All of them can also be viewed with "robocopy /?" in CMD if you want more 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).
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.
Additional official notes: /MIR and /PURGE no longer touch System Volume Information in roots; "modified classification" requires file systems that support change times; /DCOPY:E attempts to copy extended attributes in directories; limiting parameters can be adjusted and the system may enforce valid limits; /LFSM sets the floor to 10% of the volume if no value is provided and 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
Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.