RoboCopy (Robust File Copy) is a command-line tool in Windows. It is intended for consistent copying or mirroring of directories wherever the computer has access, including local drives, removable drives, Local Area Network, remote servers, and in the process guarantees that all file properties and permissions stay integral.
This article deals about the Robocopy Command-line tool with Examples and Switches.

Syntax Examples:

robocopy source destination [file [file] ... ] [parameters]
  • source: specifies source folder. You can use drive:\path or \\server\share\path here.
  • destination: specifies the destination folder. You can use drive:\path or \\server\share\path here.
  • file: Files to process. Wildcard characters are supported (* match any sequence of characters,?: match a single character)
  • parameters: Command-line switches you wish to use. You can find the entire list at the end of this document.

Copy  Folder

The most simple operation with robocopy is copying sources folders to the destination
In this example, we will copy the directory C:\Temp  to the destination folder E:\Temp

robocopy  “C:\Temp“  “E:\Temp“
After copy operation, some data are provided by robocopy

·         Start shows the start time of copy operation

·         Source shows source directory

·         Dest shows destination directory

·         Files shows file filter

·         Options shows given options

·         Total shows total files and folders count

·         Copied shows copied files and folders, count

·         Skipped shows not copied files and folders


Copy a file to a remote system or share

Similarly, we can copy files and folders to the remote system. We will provide remote system’s hostname or IP address before the destination path. We can use \\server1\share or \\ to specify remote system.
In this example we will copy source directory named C:\Temp  to the remote system with IP address under the path shared with the named TempShare.
robocopy “C:\Temp” \\\share\TempShare

Copy files of a specific extension

robocopy provides some filtering features while copying files. We can specify the filenames and extensions we want to copy. This will skip other file named and extensions. We will provide the file name or extension after the destination folder.
In this example, we only want to copy *.txt extension files.
robocopy "C:\Temp" "E:\Temp"  *.txt

Copy subfolders

By default, only first level directories are copied to the destination. If we want to copy all directories and subdirectories, folders we should enable /S switch.
robocopy “C:\Temp” “E:\Temp” /S


List Files

This is a very useful feature for robocopy where source files are not copied and just listed. This feature can be valuable if we want to check current files and folders. We can use /L option for the print list of files and directories.
robocopy “C:\Temp” “E:\Temp” /L
 As we can see from the output that all files and folders are skipped and not copied.

List Files recursively

While robocopy is primarily used to copy files from remote to local or local to remove we can use /L and /S choices in order to

list remote files. We can merge two options list and recursive to list all level files and folders.
 robocopy “C:\Temp” “E:\Temp” /L /S

Copy Files Lesser than specified Size

While copying files we can state the size of files we want to copy. In this example we will copy files those sizes are lower than 1K

. We will use /MAX option for this.
robocopy “C:\Temp” “E:\Temp” /S /MAX:1000


Copy Files greater than specified Size

To do so we can use switch /MIN . This will only copy files higher than the given size.
In this example, we will copy files higher than 1K which is 1000 kilobyte.
 robocopy “C:\Temp” “E:\Temp” /S /MIN:1000


Move Files

 The default behavior of robocopy is copying files. Occasionally we may have to move files. This can be done with robocopy too. We will provide /MOV option in order to move files and folders.
 robocopy “C:\Temp” “E:\Temp” /S /MOVE

Get the logs of robocopy operation

While doing copy and move operations we can also need some logs, especially in bulk data operations. We can write a log about specified operations with /LOG option. We can also specify the log file name y adding at the end of /LOG option. In this example, we will write robocopy operation log to a log file named backup.log . This will prevent regular output
robocopy “C:\Temp” “E:\Temp” /S /LOG:backup.log

The log file can be listed with type command in MS-DOS command line like below.
type backup.log.Alternatively, you can also open the log file in notepad

Copy  specified File Properties

 Files and folders could have different properties. These properties can be used for different purposes like the listing owner, audit information, timestamps etc. We can copy these attributes too with the robocopy command. Here is the attributed we can specify for the copy. We will also use /copy: option by adding the property we want to copy.

·         D is used to copy data properties

·         A used for attributes

·         T for timestamps

·         S is used for NTFS access control list simply ACL

·         is used for the owner information

·         U is used for Auditing information

In this example, we will copy time stamp attributes or properties with the following command.
robocopy “C:\Temp” “E:\Temp” /S /copy:T

Copy All Attributes with /copyall

We can also copy files with all properties of attributes with the /copyall parameter like below. This is equal to the /copy:DATSOU.
 robocopy “C:\Temp” “E:\Temp” /S /copyall

Delete or Remove Destination Files and Directories That No Longer Exist In The Source

If we are trying to make an identical copy of the local files and directories to the remote we need to purge or remove remote files and directories that no longer exist in the source. We can use /purge option for this.
robocopy “C:\Temp” “E:\Temp” /purge


Robocopy Switches

Copy options:

/S : Copy sub-folders.
/E : Copy sub-folders, including empty sub-folders.
/Z : Copy files with resume support.
/B : Copy files in Backup mode.
/SL: Copy symbolic links instead of the target.
/ZB : Copy files using resume support; if access denied use Backup mode.
/EFSRAW : Copy encrypted files using EFS RAW mode.
/LEV:n : Copy only top n levels of the source folder tree.
/DCOPY:T : Copy Folder Timestamps.
/COPY:copyflag[s] : Specifiy what file information to copy. Copyflags: D=Data, A=Attributes, T=Timestamps, S=Security=NTFS ACLs, O=Owner info, U=Auditing info.
/COPYALL : Copy all file information.
/NOCOPY : Copy no file information.                              
/SECFIX : Fix all files security.
/TIMFIX : Fix all files time.
/PURGE : Delete destination files/folders that no longer exist in source.
/MIR : Mirror folder structure.
/MOV : Move files.
/MOVE : Move files and folders.
/A+:[RASHCNET] : Add attributes to destination files.
/A-:[RASHCNET] : Remove attributes from destination files.          
/CREATE : Create folder structures and zero-length files only.
/FAT : Create destination files using 8.3 FAT file names only.
/256 : Disable very long path (> 256 characters support).
/MON:n : Monitor source, and run again when more than n changes seen.
/MOT:m : Monitor source; and 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 basis.
/IPG:n : Inter-Packet Gap (ms) to free bandwidth on slow lines.

File Selection Options:

/A : Files with Archive attribute set.
/M : Files with the Archive attribute and remove it.
/IA:[RASHCNETO] : Include files with specific attributes set.
/XA:[RASHCNETO] : Exclude files with specific attributes set.
/XF file [file]... : Exclude Files matching given names/paths/wildcards.
/XD dirs [dirs]... : Exclude folders matching given names/paths.
/XC : Exclude Changed files.
/XN : Exclude Newer files.
/XO : Exclude Older files.
/XX : Exclude extra files present in destination folder but not in source. This will prevent deletion of existing files in destination folder.
/XL : Exclude files and folders present in source but not destination. This switch will prevent new files being added to the destination
/IS : Overwrite existing files even if they are same.
/IT : Include files with identical size and timestamp, but different attribute settings.
/MAX:n : Exclude files bigger than n bytes.
/MIN:n : Exclude files smaller than n bytes.
/MAXAGE:n : Exclude files older than n days/date.
/MINAGE:n : Exclude files newer than n days/date.
/MAXLAD:n : Exclude files unused since n days.
/MINLAD:n : Exclude files used since n days.
/XJ : Exclude Junction points
/FFT : FAT File Times (2-second granularity.
/DST : Compensate for one-hour DST time differences.
/XJD : Exclude Junction points for Folders.
/XJF : Exclude Junction points for Files.

Retry Options:

/R:n : Number of Retries on failed copies: default 1 million.
/W:n : Wait n time between retries: default is 30 seconds.
/TBD : Wait for sharenames to be defined.

Logging Options:

/L : List only.
/X : Report all extra files.
/V : Verbose output.
/TS : Include source file Time Stamps.
/FP : Include Full Pathname of files.
/BYTES : Print file sizes as bytes.
/NS : Don't log file sizes.
/NC : Don't log file classes.
/NFL : Don't log file names.
/NDL : Don't log folder names.
/NP : Don't show progress of operation.
/ETA : Show Estimated Time of Arrival of copied files.
/LOG:file : Output status to a LOG file. Overwrite existing file
/LOG+:file : Append existing output status to an existing LOG file.
/UNILOG:file : Output status to a Unicode LOG file. Overwrite existing file
/UNILOG+:file : Append existing output status to an existing Unicode LOG file.
/TEE : Output to console window and log file.
/NJH : Don't output Job Header.
/NJS : Don't output Job Summary.

Pause Robocopy :

check with PsSupend to pause the process without killing it

Job Options:

/JOB:jobname : Take parameters from specified job file.
/SAVE:jobname : Save parameters to a specific job file.
/QUIT : QUIT after processing.
/NOSD : NO Source Folder is specified.
/NODD : NO Destination Folder is specified.
/IF : Include the following Files.