robocopy flags

Robocopy Flags: The Ultimate Guide to Faster, Safer File Copies

By Jessica Jackson
AD

Robocopy flags are the command-line switches that tell the Windows Robocopy utility exactly how to copy, mirror, move, or synchronize files and folders. Built into modern versions of Windows, Robocopy is far more powerful than a simple drag-and-drop operation, but that power only becomes useful when you understand the flags that control its behavior. A single switch can change whether empty folders are copied, whether security permissions are preserved, how many times a locked file is retried, or whether the destination is purged to match the source exactly.

Without flags, Robocopy behaves like a basic file copy tool with some default retry logic and a plain console output. With the right Robocopy flags, it becomes a reliable engine for backups, server migrations, scheduled sync jobs, and large-scale file transfers. The key is knowing which switches matter for your scenario and which ones can cause unexpected deletions or permission changes if used carelessly.

Essential Robocopy Flags for Core File Operations

At its core, Robocopy copies a source directory to a destination directory. The basic syntax is robocopy source destination [file [file]...] [options], where the options are the flags that customize the job. Even a simple copy can behave differently depending on whether you include subdirectories, empty folders, hidden files, and file attributes. The flags in this section form the foundation of most everyday Robocopy commands.

AD
no credit : hover over flag for names
no credit : hover over flag for names
Robocop (movies serie)
Robocop (movies serie)
robotkin flag
robotkin flag

Before running any Robocopy command that modifies data, test it with the /L flag. This switch lists what would be copied or deleted without actually performing the operation. It is one of the most valuable safety flags in the entire tool, especially when you combine it with mirroring or purging options that can remove files from the destination.

Mirroring and Directory Structure Flags

The /E flag copies all subdirectories, including empty ones. By contrast, /S copies subdirectories but skips empty directories. If you need an exact mirror of the source, /MIR is the classic choice because it combines /E with /PURGE. That means it copies everything from the source and deletes destination files and folders that no longer exist in the source. /MIR is incredibly useful for backups, but it is also unforgiving, so always verify the source and destination paths before running it.

Robophilia flag
Robophilia flag
Robosexuality
Robosexuality
several different flags are displayed on a white surface with words written in spanish and english
several different flags are displayed on a white surface with words written in spanish and english

Other directory-related flags give you finer control. /LEV:n limits the copy to the top n levels of the source tree. /MOVE moves files and directories after copying, while /MOV moves files only. /CREATE builds the directory tree and creates zero-length files without copying data. /XD excludes specific directories, and /XF excludes specific files. For example, robocopy C:\Projects D:\Projects /E /XD node_modules .git /XF *.tmp copies the project while skipping heavy or temporary items.

File Attribute, Retry, and Copy Behavior Flags

The /COPY flag defines what file properties are copied. /COPY:DAT is the default and includes data, attributes, and timestamps. Add S for security, O for owner, and U for auditing, or use /COPYALL as a shorthand for /COPY:DATSOU. When you need directory timestamps preserved, use /DCOPY:T. These flags matter in migrations where NTFS permissions, ownership, and time stamps must remain intact for applications or compliance reasons.

AD

Retry behavior is controlled by /R:n and /W:n. /R sets the number of retries on failed copies, and /W sets the wait time between retries in seconds. For unattended scripts, /R:0 /W:0 prevents Robocopy from hanging on a locked file, though it also means a failed file is skipped quickly. /Z enables restartable mode, /B enables backup mode, and /ZB tries restartable mode first and falls back to backup mode if access is denied. /J uses unbuffered I/O, which can help with very large files, while /EFSRAW copies encrypted files in raw mode.

robotic
robotic
ROBOTGENDER FLAG !! ☆
ROBOTGENDER FLAG !! ☆
RoboPupGender
RoboPupGender
Robotic adjective flag
Robotic adjective flag
- ROBOTBOYTHING!
- ROBOTBOYTHING!
(req) decorated computerkin and robotkin flags!!
(req) decorated computerkin and robotkin flags!!

Advanced Robocopy Flags for Filtering, Logging, and Performance

Once you are comfortable with the core switches, advanced Robocopy flags let you shape jobs around business rules. You can exclude older files, limit copies by age, monitor a source folder for changes, throttle bandwidth, and produce detailed logs for auditing. These options are common in enterprise backup scripts, nightly synchronization tasks, and migrations where every byte and permission matters.

Advanced flags also introduce risk because they interact with each other. For example, combining /MIR with exclusion flags can produce a destination that mirrors only part of the source, while /PURGE can remove files that were intentionally excluded. Reading the documentation and testing with /L is not optional when you move beyond basic copying.

AD

Selection and Exclusion Flags

Selection flags decide which files are eligible for copying. /XO excludes older files, /XN excludes newer files, and /XC excludes changed files. /MAXAGE:n and /MINAGE:n filter by file age in days or by date. /MAXLAD:n and /MINLAD:n filter by last access date. /XA excludes files with specific attributes, such as hidden or system files. /IF includes files, while /IM includes modified files. These switches are useful when you only want to copy recent documents, skip unchanged files, or avoid touching files that are still being edited.

retroslopgender
retroslopgender
a black and white logo with two gears
a black and white logo with two gears
robot flag (no symbol)
robot flag (no symbol)
Robotlink ⚙️
Robotlink ⚙️

Exclusion flags are equally important. /XD excludes directories by name or path, and /XF excludes files by name, path, or wildcard. For example, robocopy D:\Data E:\Backup /E /XO /MAXAGE:14 /XD AppData Temp /XF *.iso *.vhd copies only files modified within the last 14 days while skipping large disk images and temporary directories. Use /L with these filters first to confirm that the selection matches your intent.

Performance, Logging, and Security Flags

Performance flags help Robocopy handle large jobs efficiently. /MT:n enables multithreaded copying, with n typically set between 8 and 32, though values up to 128 are allowed. Multithreading can dramatically speed up transfers of many small files, but it is not compatible with every other switch, so check interactions before using it in production. /IPG:n inserts a delay between packets to reduce network saturation, while /RH:hhmm-hhmm restricts copying to specific hours. /PF checks run hours per file rather than per job.

AD

Logging flags make Robocopy suitable for scheduled tasks and audits. /LOG:file writes a log, /LOG+:file appends to an existing log, and /TEE sends output to both the console and the log. /NP removes percentage progress, /NFL hides file names, /NDL hides directory names, /NJH hides the job header, and /NJS hides the job summary. /TS adds timestamps, /FP shows full paths, /BYTES reports sizes in bytes, and /ETA estimates remaining time. For security, /SEC copies NTFS permissions, /SECFIX fixes permissions on skipped files, /TIMFIX fixes timestamps, and /COPYALL preserves the full set of file and folder properties.

The best way to master Robocopy flags is to start with a small test folder and a simple command, then add one switch at a time while checking the results with /L and a log file. Once you have a reliable combination for your backup, migration, or sync workflow, save it as a script or scheduled task so it can run consistently without manual intervention. With careful testing, Robocopy becomes less of a mysterious command-line tool and more of a dependable part of your Windows file management routine.

AD