Robocopy command in Windows

The robocopy command helps copy data files

The robocopy command helps copy data files.

Robocopy command

  1. Robocopy command syntax
  2. Robocopy command parameter
  3. Copy options
  4. File selection options
  5. Retry options (Retry options)
  6. Job options (job options)
  7. Exit codes (returned results)
  8. Robocopy command comment

Robocopy command syntax

 robocopy [[.]] [] 

Robocopy command parameter

Parameters

Describe

 

Specify the path to the source directory.

 

Specify the path to the destination directory.

 

Specify the file or set of files to copy. You can use wildcards (* or?), If desired. If the File parameter is not specified, the characters *. * will be used as the default value.

 

Specify the options used with the robocopy command.

Copy options

Option

Describe

/S

Copy subdirectories. Note that this option will ignore empty directories.

/ e

Copy subdirectories. Note that this option will include empty folders. For more information, see the glossary at the bottom of the article.

/ lev:

Copy only the folders located in the highest N levels of the directory tree.

/ z

Copy files in restartable mode.

/ b

Copy files in backup mode.

/ zb

Use restart mode. If access is denied, this option will use backup mode.

/ efsraw

Copy all encrypted files in EFS RAW mode.

/copy:

Specify the properties of the file to be copied. Here are the valid values ​​for this option:

  1. D Data (data)
  2. A Attributes (attributes)
  3. T Time stamps (by time interval)
  4. S NTFS access control list (ACL) (NTFS access control list)
  5. O Owner information (owner information)
  6. U Auditing information (test information)

The default value for the CopyFlags parameter is DAT (data, attributes, and duration).

/ dcopy:

Determine what to copy for the folders. Default is DA. Options are D = data, A = attribute and T = time interval.

/ sec

Copy files with security (equivalent to the parameter / copy: DATS).

/ copyall

Copy all file information (equivalent to the parameter / copy: DATSOU).

/ nocopy

Do not copy file information (useful when using with / purge parameter).

/ secfix

Edit the file security (file security) on all files, even if the files are ignored.

/ timfix

Edit the time information (file times) on all files, even if the files have been ignored.

/ purge

Delete destination and directory files that no longer exist in the source. For more information, see the glossary at the bottom of the article.

/ mir

Reflect a directory tree (equivalent to the / e parameter plus / purge). For more information, see the glossary at the bottom of the article.

/ mov

Move files and delete them from the source after they have been copied.

/ move

Move files and folders and delete them from the source after they have been copied.

/ a +: [RASHCNET]

Add the specified attributes to the copied files.

/ a -: [RASHCNET]

Remove specified attributes from copied files.

/ create

Create a directory tree and files with a length of 0.

/ fat

Create the destination file by using only the FAT file name with a character length of 8.3.

/ 256

Disable support for paths that are too long (longer than 256 characters).

/ mon:

Monitor the source and run again when more than N changes are detected.

/ mot:

Monitor the source and run again after M minutes if a change is detected.

/ MT [: N]

Create multi-threaded copies with N threads. N must be an integer between 1 and 128. The default value for N is 8.

The parameter / MT cannot be used together with the parameter / IPG and / EFSRAW.

Redirecting for the output file using the option / LOG will give better performance.

Note: The / MT parameter only applies to Windows Server 2008 R2 and Windows 7.

/ rh: hhmm-hhmm

Specify runtime when you can start new copies.

/ pf

Check the runtime on the basis of each file (not every transmission).

/ ipg: n

Specify packet spacing with free bandwidth on slow connections.

/ sl

Follow the symbolic link and proceed to copy according to the goal.

Attention

When using the copy / SECFIX option, specify the type of security information you want to copy using one of the following additional copy options:

> - COPYALL

> - / COPY: O

> - / COPY: S

> - / COPY: U

> - / SEC

File selection options

Option

Describe

/ a

Only copy files that have an Archive property set.

/ m

Only copy files where the Archive attribute is set and then reset the Archive property.

/ ia: [RASHCNETO]

Only select files that are set to all attributes as specified.

/ far: [RASHCNETO]

Exclude files that are set to all attributes as specified.

/ xf [.]

Exclude files that match the specified name or path. Note that FileName may include wildcards (* and?).

/ xd [.]

Exclude folders that match the names and paths specified.

/ xc

Exclude changed files.

/ xn

Exclude newer files.

/ xo

Exclude older files.

/ xx

Exclude additional files and folders.

/ xl

Exclude individual files and folders.

/ is

Select the same files.

/ it

Select files that have been "refined".

/ max:

Specify the maximum file size (to exclude files larger than N bytes).

/ min:

Specify the minimum file size (to exclude files smaller than N bytes).

/ maxage:

Specify the maximum 'age' of the file (to exclude files older than N days).

/ minage:

Specify the minimum 'age' of the file (to exclude files older than N days).

/ maxlad:

Specify the last date to access the file, how long is the most current time (ie do not select files that have not been used since the last N days).

/ minlad:

Specify the last timeline to access the file at least the current time (ie do not select files that have been used since the last N days). If N is less than 1900, N will specify the number of days. If not, N will specify a timestamp in YYYYMMDD format.

/ xj

Do not select the intersection points, this parameter will usually be applied by default.

/ fft

Assume the time for the FAT file (accuracy of two seconds).

/ dst

In return for DST time difference in an hour.

/ xjd

Do not select the intersection points of the directories.

/ xjf

Do not select the intersection points of the files.

Retry options (Retry options)

Option

Describe

/ r:

Specifies the number of retries for unsuccessful copies. The default value of N is 1,000,000 (one million retries).

/ w:

Specify the timeout between retries, in seconds. The default value of N is 30 (30 seconds standby time).

/ reg

Save the values ​​specified in the / r option and / w as the default settings in the registry.

/ tbd

Specifies that the system will wait until the shared names are determined (retry error 67).


Logging options

Option

Describe

/ l

Specifies that the files will only be listed (and cannot be copied, deleted or timed).

/ x

Report all secondary files, not just selected files.

/ v

Create detailed outputs and display all skipped files.

/ ts

Attach the duration of the source file to the output.

/ fp

Include the full path name of the files in the output.

/ bytes

Size of prints, in bytes

/ ns

Specifies that the size of the files will not be recorded.

/ nc

Specifies that the file's class will not be recorded.

/ nfl

Specifies that the file name will not be logged.

/ ndl

Specifies that the folder name will not be recorded.

/ np

Specifies that information about the progress of a copy operation (the number of files or folders copied to date) will not be displayed.

/ eta

Displays the expected completion time (ETA) of the copied files.

/ log:

Write the output status to the log file (overwrite the existing log file).

/ log +:

Write the output status to the log file (write the serial to the existing log file).

/ unicode

Display output status as Unicode text.

/ unilog:

Record the output status to the log file as Unicode text (overwrite the existing log file).

/ unilog +:

Write the output status to the log file as Unicode text (write serially to the existing log file).

/ tee

Write the output to the console window as well as the log file.

/ njh

Specify that there is no job title (job header).

/ njs

Assign that there is no work summary (job summary).

Job options (job options)

Option

Describe

/ job:

Specifies that the parameters will be derived from the named job file (named job file).

/ save:

Specifies that the parameters will be saved to the named work file.

/ quit

Specifies exit after command line processing (for viewing parameters).

/ nosd

Indicates that no source directory is specified.

/ nodd

Indicates that no destination folder is specified.

/ if

Attach the specified files.

Exit codes (returned results)

Value

Describe

first

No files are copied. No errors were encountered. All files match. The file already exists in the destination directory. Therefore, copying operations cannot be performed and have been ignored.

2

All files have been successfully copied.

3

There are some additional files in the destination directory that are not in the source directory. No files are copied.

4

Some files have been copied. Additional files have been detected. No errors were encountered.

5

Some files have been copied. Some files do not match. No errors were encountered.

6

Additional files and files did not match. No files were copied and no errors were encountered. This means the files already exist in the destination directory.

7

Files that have been copied, files do not match, and additional files have been detected.

8

Some files cannot be copied.

Note

Any value greater than 8 will indicate that at least one error occurred during the copy process.

Robocopy command comment

The optional / mir parameter is equivalent to the / e option along with / purge, there are only some minor differences in behavior as follows:

  1. With the / e option and / purge, if the destination folder exists, the destination folder security settings will not be overwritten.
  2. With the / mir option, if the destination folder exists, the target folder security settings will be overwritten.

See more:

  1. Summary of 20 common Run commands on Windows operating system
  2. Summary of shortcuts to know in Windows 10
  3. Basic Linux commands everyone needs to know
  4. Table summarizes the basic PowerShell commands
Update 26 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile