NT Syntax

ROBOCOPY.exe (Resource Kit)

Robust File and Folder Copy.
By default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes.

      ROBOCOPY source_folder destination_folder [file(s)_to_copy] [options]

   file(s)_to_copy : A list of files or a wildcard.
                     If no source "file(s)_to_copy" are specified robocopy
                     will default to copying *.*
   Source options
                /S : copy Subfolders
                /E : copy Subfolders, including Empty Subfolders.
              /SEC : copy SECurity info (both source and dest must be NTFS).##

                /A : copy only files with the Archive attribute set.
                /M : like /A, but remove Archive attribute from source files.
            /LEV:n : only copy the top n LEVels of the source tree.##

         /MAXAGE:n : MAXimum file AGE - exclude files older than n days/date.##
         /MINAGE:n : MINimum file AGE - exclude files newer than n days/date.##
                     (If n < 1900 then n = n days, else n = YYYYMMDD date).

   Copy options
                /L : List only - don't copy, timestamp or delete any files.
              /MOV : MOVe files (delete from source after copying).##
             /MOVE : Move files and dirs (delete from source after copying).

                /Z : copy files in restartable mode (survive network glitch).##

              /R:n : number of Retries on failed copies - default is 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).##

   Destination options

  /A+:[R][A][S][H] : set file Attributes on destination files - add.
  /A-:[R][A][S][H] : set file Attributes on destination files - remove.
              /FAT : create destination files using 8.3 FAT file names only.##
           /SECFIX : FIX SECurity info on existing files and dirs.##
           /TimFix : FIX Timestamp on all existing destination files,
                     including skipped files. ##
                     (prior to version 1.95 this was /T it's not backwards compatible
                      so scripts that use /T may fail)

           /CREATE : CREATE directory tree structure + zero-length files only.

            /PURGE : delete dest files/folders that no longer exist in source.
              /MIR : MIRror a directory tree - equivalent to /PURGE plus all subfolders (/E) ##

   Logging options
                /L : List only - don't copy, timestamp or delete any files.
               /NP : No Progress - don't display % copied.
         /LOG:file : output status to LOG file (overwrite existing log). ##
        /LOG+:file : output status to LOG file (append to existing log). ##

Advanced options you'll probably never use
               /XO : eXclude Older - if destination file exists and is the same date
                     or newer than the source - don't bother to overwrite it.
         /XC | /XN : eXclude Changed | Newer files
         /XX | /XL : eXclude eXtra | Lonely files and dirs. 
                     An "extra" file is present in destination but not source, 
                     excluding extras will delete from destination. 
                     A "lonely" file is present in source but not destination
                     excluding lonely will prevent any new files being added to the destination.
               /IS : Overwrite files even if they are already the same.

/XF file [file]... : eXclude Files matching given names/paths/wildcards.##
/XD dirs [dirs]... : eXclude Directories matching given names/paths.    ##
                     XF and XD can be used in combination  e.g.
                     ROBOCOPY c:\source d:\dest /XF *.doc *.xls /XD c:\unwanted /S 

            /MAX:n : MAXimum file size - exclude files bigger than n bytes. ##
            /MIN:n : MINimum file size - exclude files smaller than n bytes.##

/XA:[R][A][S][H] : eXclude files with any of the given Attributes /IA:[R][A][S][H] : Include files with any of the given Attributes ## /X : report all eXtra files, not just those selected & copied. /V : produce Verbose output log, showing skipped files. /ETA : show Estimated Time of Arrival of copied files. ## indicates a new feature in Robocopy version 1.95

ROBOCOPY will accept UNC pathnames.


ROBOCOPY \\Server1\reports \\Server2\reports *.doc /S /NP

Incomplete copies
If you terminate Robocopy during a copy operation (e.g if the Command Prompt window is closed), any incompletely copied destination file will be left with a later time stamp than it's corresponding source file.
This behaviour is different to both COPY and XCOPY which will either copy the whole file successfully or won't create a destination file at all.

If you restart the same Robocopy operation using the /XO switch, Robocopy will treat the file as an Older file and will skip it - leaving the half-copied file in place.

For the rare occasions where /XO is needed - a workaround is to RENAME the destination folder, run ROBOCOPY and then RENAME the folder back again. That way if the script is interrupted part way through, the folder will be left with the 'wrong' name which is easy to detect and clean up.

"When a thing has been said and well said, have no scruple; take it and copy it".- Anatole France

Related Commands:

COPY - Copy one or more files to another location
SCOPY - Copy complete with NTFS Security Permissions
XCOPY - Copy files and folders
Fcopy - File Copy for MMQ (copy changed files & compress. (Win 2K ResKit)
Permcopy - Copy share & file ACLs from one share to another. (Win 2K ResKit)
The Directory Replicator Service - but this requires exclusive access to Netlogon and REPL$.

Equivalent Linux BASH commands:

rsync - Synchronize file trees
remsync - Synchronize remote files
cp - Copy one or more files to another location

Simon Sheppard