Robocopy command
![robocopy command](/cdn/dos/robocopy-command.gif)
Robocopy is a robust file copy command for the Windows command line. It allows users to copy files, directories, and drives from one location to another.
Availability
Robocopy is an external command available for the following Microsoft operating systems as robocopy.exe.
- Windows NT (In resource kit)
- Windows 2000 (In resource kit)
- Windows Server 2008
- Windows Vista
- Windows 7
- Windows 8
- Windows 10
- Windows 11
Robocopy syntax
Windows 10 and 11 syntax
ROBOCOPY source destination [file [file]...] [options]
source | Source directory (drive:\path or \\server\share\path). |
destination | Destination directory (drive:\path or \\server\share\path). |
file | File(s) to copy (names/wildcards: default is "*.*"). |
Copy options
/S | Copy subdirectories, but not the empty ones. |
/E | Copy subdirectories, including the empty ones. |
/LEV:n | Only copy the top n levels of the source directory tree. |
/Z | Copy files in restartable mode. |
/B | Copy files in backup mode. |
/ZB | Use restartable mode. If access is denied, use backup mode. |
/J | Copy using unbuffered I/O (recommended for large files). |
/EFSRAW | Copy all encrypted files in EFS RAW mode. |
/COPY:[copyflags] | What to COPY for files (default is /COPY:DAT). (copyflags: D=Data, A=Attributes, T=Timestamps). (S=Security=NTFS ACLs, O=Owner info, U=aUditing info). |
/SEC | Copy files with security (equivalent to /COPY:DATS). |
/COPYALL | Copy all file info (equivalent to /COPY:DATSOU). |
/NOCOPY | Copy no file info (useful with /PURGE). |
/SECFIX | Fix file security on all files, even skipped files. |
/TIMFIX | Fix file times on all files, even skipped files. |
/PURGE | Delete dest files/dirs that no longer exist in the source. |
/MIR | Mirror a directory tree (equivalent to /E plus /PURGE). |
/MOV | Move files (delete from the source after copying). |
/MOVE | Move files and dirs (delete from the source after copying). |
/A+:[RASHCNET] | Add the given attributes to copied files. |
/A-:[RASHCNET] | Remove the given attributes from copied files. |
/CREATE | Create directory tree and zero-length files only. |
/FAT | Create destination files using 8.3 FAT file names only. |
/256 | Turn off a very long path (> 256 characters) support. |
/MON:n | Monitor source; run again when more than n changes are shown. |
/MOT:m | Monitor source; run again in m minutes time, if changed. |
/RH:hhmm-hhmm | Run hours - times when new copies may be started. |
/PF | Check run hours on a per file (not per pass) basis. |
/IPG:n | Inter-packet gap (ms), to free bandwidth on slow lines. |
/SJ | Copy junctions as junctions instead of as the junction targets. |
/SL | Copy symbolic links as links instead of as the link targets. |
/MT[:n] | Do multi-threaded copies with n threads (default 8). n must be at least 1 and not greater than 128. This option is incompatible with the /IPG and /EFSRAW options. Redirect output using /LOG option for better performance. |
/DCOPY:[copyflags] | What to copy for directories (default is /DCOPY:DA). (copyflags : D=Data, A=Attributes, T=Timestamps, E=EAs, X=Skip alt data streams). |
/NODCOPY | Copy no directory info (the default /DCOPY:DA is done). |
/NOOFFLOAD | Copy files without using the Windows Copy Offload mechanism. |
/COMPRESS | Request network compression during file transfer, if applicable. |
Copy File Throttling options
The Copy File Throttling options are only available in Windows 11.
/IoMaxSize:n[KMG] | Requested max I/O size per {read,write} cycle, in n [KMG] bytes. |
/IoRate:n[KMG] | Requested I/O rate, in n [KMG] bytes per second. |
/Threshold:n[KMG] | File size threshold for throttling, in n [KMG] bytes (see Remarks). |
File Selection options
/A | Copy only the files with the archive attribute set. |
/M | Copy only the files with the archive attribute and reset it. |
/IA:[RASHCNETO] | Include only the files with any of the given attributes set. |
/XA:[RASHCNETO] | Exclude files with any of the given attributes set. |
/XF file [file]... | Exclude files matching given names/paths/wildcards. |
/XD dirs [dirs]... | Exclude directories matching given names/paths. |
/XC | Exclude changed files. |
/XN | Exclude newer files. |
/XO | Exclude older files. |
/XX | Exclude extra files and directories. |
/XL | Exclude lonely files and directories. |
/IS | Include same files. |
/IT | Include tweaked files. |
/MAX:n | Maximum file size - exclude files bigger than n bytes. |
/MIN:n | Minimum file size - exclude files smaller than n bytes. |
/MAXAGE:n | Maximum file age - exclude files older than n days/date. |
/MINAGE:n | Minimum file age - exclude files newer than n days/date. |
/MAXLAD:n | Maximum last access date - exclude files unused since n. |
/MINLAD:n | Minimum last access date - exclude files used since n. (If n < 1900 then n = n days, else n = YYYYMMDD date). |
/FFT | Assume FAT file times (2-second granularity). |
/DST | Compensate for one-hour DST time differences. |
/XJ | Exclude symbolic links (for both files and directories) and junction points. |
/XJD | Exclude symbolic links for directories and junction points. |
/XJF | Exclude symbolic linksfor files. |
/IM | Include modified files (differing change times). |
Retry options
/R:n | Number of retries on failed copies: default 1 million. |
/W:n | Wait time between retries: default is 30 seconds. |
/REG | Save /R:n and /W:n in the registry as default settings. |
/TBD | Wait for sharenames to be defined (retry error 67). |
/LFSM | Operate in low free space mode, enabling copy pause and resume (see Remarks). |
/LFSM:n[KMG] | /LFSM, specifying the floor size in n [K:kilo,M:mega,G:giga] bytes. |
Logging options
/L | List only - don't copy, timestamp or delete any files. |
/X | Report all extra files, not only those selected. |
/V | Produce verbose output, showing skipped files. |
/TS | Include source file timestamps in the output. |
/FP | Include full pathname of files in the output. |
/BYTES | Print sizes as bytes. |
/NS | No size - don't log file sizes. |
/NC | No class - don't log file classes. |
/NFL | No file list - don't log file names. |
/NDL | No directory list - don't log directory names. |
/NP | No progress - don't display percentage copied. |
/ETA | Show estimated time of arrival of copied files. |
/LOG:file | Output status to LOG file (overwrite existing log). |
/LOG+:file | Output status to LOG file (append to existing log). |
/UNILOG:file | Output status to LOG file as UNICODE (overwrite existing log). |
/UNILOG+:file | Output status to LOG file as UNICODE (append to existing log). |
/TEE | Output to console window and the log file. |
/NJH | No job header. |
/NJS | No job summary. |
/UNICODE | Output status as UNICODE. |
Job options
/JOB:jobname | Take parameters from the named job file. |
/SAVE:jobname | Save parameters to the named job file. |
/QUIT | Quit after processing command line (to view parameters). |
/NOSD | No source directory is specified. |
/NODD | No destination directory is specified. |
/IF | Include the following files. |
Remarks
Using /PURGE or /MIR on the root directory of the volume formerly caused robocopy to apply the requested operation on files inside the System Volume Information directory as well. That is no longer the case. If /PURGE or /MIR is specified, robocopy skips any files or directories with that name in top-level source and destination directories of the copy session.
The modified files classification applies only when source and destination filesystems support change timestamps (e.g., NTFS), and the source and destination files have different change times. These files are not copied by default; specify /IM to include them.
The /DCOPY:E flag requests that extended attribute copying should be attempted for directories. Note that currently robocopy continues if a directory's EAs could not be copied. This flag is also not included in /COPYALL.
Using /LFSM requests robocopy to operate in 'low free space mode'. In that mode, robocopy pauses whenever file copying would cause the destination volume's free space to go below a 'floor' value, which can be explicitly specified by the LFSM:n[KMG] form of the flag. If /LFSM is specified with no explicit floor value, the floor is set to ten percent of the destination volume's size. Low free space mode is incompatible with /MT, /EFSRAW, /B, and /ZB.
Windows 8 and earlier syntax
ROBOCOPY source destination [file [file]...] [options]
source | Source directory (drive:\path or \\server\share\path). |
destination | Destination directory (drive:\path or \\server\share\path). |
file | File(s) to copy (names/wildcards: default is "*.*"). |
Copy options
/S | Copy subdirectories, but not the empty ones. |
/E | Copy subdirectories, including the empty ones. |
/LEV:n | Only copy the top n levels of the source directory tree. |
/Z | Copy files in restartable mode. |
/B | Copy files in backup mode. |
/ZB | Use restartable mode. If access denied, use backup mode. |
/EFSRAW | Copy all encrypted files in EFS RAW mode. |
/COPY:[copyflags] | What to COPY for files (default is /COPY:DAT). (copyflags : D=Data, A=Attributes, T=Timestamps). (S=Security=NTFS ACLs, O=Owner info, U=aUditing info). |
/DCOPY:T | COPY the directory timestamps. |
/SEC | Copy files with security (equivalent to /COPY:DATS). |
/COPYALL | Copy all file info (equivalent to /COPY:DATSOU). |
/NOCOPY | Copy no file info (useful with /PURGE). |
/SECFIX | Fix file security on all files, even skipped files. |
/TIMFIX | Fix file times on all files, even the skipped ones. |
/PURGE | Delete dest files/dirs that no longer exist in the source. |
/MIR | Mirror a directory tree (equivalent to /E plus /PURGE). |
/MOV | Move files (delete from the source after copying). |
/MOVE | Move files and dirs (delete from the source after copying). |
/A+:[RASHCNET] | Add the given attributes to copied files. |
/A-:[RASHCNET] | Remove the given attributes from copied files. |
/CREATE | Create directory tree and zero-length files only. |
/FAT | Create destination files using 8.3 FAT file names only. |
/256 | Turn off very long path (> 256 characters) support. |
/MON:n | Monitor source; run again when more than n changes seen. |
/MOT:m | Monitor source; run again in m minutes time, if changed. |
/RH:hhmm-hhmm | Run hours - times when new copies may be started. |
/PF | Check run hours on a per file (not per pass) basis. |
/IPG:n | Inter-packet gap (ms), to free bandwidth on slow lines. |
/SL | Copy symbolic links versus the target. |
/MT[:n] | Do multi-threaded copies with n threads (default 8). n must be at least 1 and not greater than 128. This option is incompatible with the /IPG and /EFSRAW options. Redirect output using /LOG option for better performance. |
File Selection options
/A | Copy only the files with the archive attribute set. |
/M | Copy only the files with the archive attribute and reset it. |
/IA:[RASHCNETO] | Include only the files with any of the given attributes set. |
/XA:[RASHCNETO] | Exclude files with any of the given attributes set. |
/XF file [file]... | Exclude files matching given names/paths/wildcards. |
/XD dirs [dirs]... | Exclude directories matching given names/paths. |
/XC | Exclude changed files. |
/XN | Exclude newer files. |
/XO | Exclude older files. |
/XX | Exclude extra files and directories. |
/XL | Exclude lonely files and directories. |
/IS | Include same files. |
/IT | Include tweaked files. |
/MAX:n | Maximum file size - exclude files bigger than n bytes. |
/MIN:n | Minimum file size - exclude files smaller than n bytes. |
/MAXAGE:n | Maximum file age - exclude files older than n days/date. |
/MINAGE:n | Minimum file age - exclude files newer than n days/date. |
/MAXLAD:n | Maximum last access date - exclude files unused since n. |
/MINLAD:n | Minimum last access date - exclude files used since n. (If n < 1900 then n = n days, else n = YYYYMMDD date). |
/XJ | Exclude junction points. (normally included by default). |
/FFT | Assume FAT file times (2-second granularity). |
/DST | Compensate for one-hour DST time differences. |
/XJD | Exclude junction points for directories. |
/XJF | Exclude junction points for files. |
Retry options
/R:n | Number of retries on failed copies: default 1 million. |
/W:n | Wait time between retries: default is 30 seconds. |
/REG | Save /R:n and /W:n in the registry as default settings. |
/TBD | Wait for sharenames to be defined (retry error 67). |
Logging options
/L | List only - don't copy, timestamp or delete any files. |
/X | Report all extra files, not only those selected. |
/V | Produce verbose output, showing skipped files. |
/TS | Include source file timestamps in the output. |
/FP | Include full pathname of files in the output. |
/BYTES | Print sizes as bytes. |
/NS | No size - don't log file sizes. |
/NC | No class - don't log file classes. |
/NFL | No file list - don't log file names. |
/NDL | No directory List - don't log directory names. |
/NP | No progress - don't display percentage copied. |
/ETA | Show estimated time of arrival of copied files. |
/LOG:file | Output status to LOG file (overwrite existing log). |
/LOG+:file | Output status to LOG file (append to existing log). |
/UNILOG:file | Output status to LOG file as UNICODE (overwrite existing log). |
/UNILOG+:file | Output status to LOG file as UNICODE (append to existing log). |
/TEE | Output to console window and the log file. |
/NJH | No job header. |
/NJS | No job summary. |
/UNICODE | Output status as UNICODE. |
Job options
/JOB:jobname | Take parameters from the named job file. |
/SAVE:jobname | Save parameters to the named job file. |
/QUIT | Quit after processing command line (to view parameters). |
/NOSD | No source directory is specified. |
/NODD | No destination directory is specified. |
/IF | Include the following files. |
Robocopy examples
robocopy c:\hope c:\hope2 *.txt
In this first example, any .txt file would be copied from the hope directory into the hope2 directory. Whenever you want to copy one or more files and not a complete directory the file must be specified after the destination directory.
robocopy c:\hope c:\hope2
In the above example, the robocopy command would copy all files (not directories) in the hope directory to the hope2 directory.
robocopy c:\hope c:\hope2 /e
In the above example, all files and folders (including empty ones) are copied from the hope directory to the hope2 directory.
robocopy c:\hope c:\hope2 /MIR
This example mirrors what's in c:\hope into c:\hope2 and purge any files in the hope2 directory that don't exist in the hope directory. Use the /mir switch cautiously since it is deleting files that do not match in the destination directory.
robocopy \\computer\hope C:\hope2
Next, this example would copy any of the files in the hope directory on the network computer named computer to the current computer hope2 directory.