What flags do i use with robocopy on copy with mod date?

2

1

I'm on windows 7 and i like to copy a directory from one drive to another. I want it to be as fast as possible and what i need are

  • Modification date
  • plain file (without attributes like permission or if its an archive)
  • recourse subdirectories
  • if file exist check if the mod date and filesize match up and overwrite if it doesn't (say in case of a partial/aborted transfer)

What flags do i want? I ended up using robocopy /S /R:3 src dst. It probably does more than i need?

user3109

Posted 2012-02-23T00:30:42.443

Reputation:

Answers

2

Robocopy by "default" will skip all files that already exist at the destination, if they are identical in size and timestamp. Files that already exist at the destination, which have different attributes from the source, but are otherwise identical will be ignored (by default).

Some excerpts from the Robocopy documentation:

By default, Lonely files (and directories) are always copied, unless /XL switch is used. Changed, Newer and Older files will be considered to be candidates for copying (subject to further filtering described below), Same files will be skipped (not copied), and Extra and Mismatched files (and directories) will simply be reported in the output log.


Normally, Tweaked files are neither identified nor copied – they are usually identified as Same files by default. Only when switch /IT is used will the distinction between Same and Tweaked files be made, and only then will Tweaked files be copied.


During a copy operation Robocopy places a January 1980 time stamp on the destination file, and updates this to the source file’s time stamp only when the copy is complete. If you quit Robocopy during a copy operation, any incompletely copied destination file will therefore have an earlier time stamp than its corresponding source file. If you restart the same copy operation, Robocopy treats this file as an Newer file and will therefore complete the interrupted copy, unless you have specified /XN.


Lonely files are files that exist only on the source (normally these are always copied). Changed means the file sizes are different. Newer and Older means the timestamps don't match. Same means file size, timestamp, and attributes match. Extra means a file that only exists in the destination. And Mismatched means a file which exists in source or destination conflicts with a folder with the same name.

So, a typical use of Robocopy:

robocopy "C:\source\path" "D:\dest\path" /E /COPY:DT /DCOPY:T /XJ

should do what you want.

  • Modification date is used to determine Newer file.
  • /COPY:DT will not change the attributes of identical files that already exist in the destination, but new (Lonely) files will be copied with their attributes.
  • /S or /E will recurse subdirectories
  • partial/aborted transfers will be resumed

Some options to use:

/S        also copy subdirs of source to destination (do not copy empty subdirs)
/E        also copy subdirs of source to destination (include empty subdirs)
/COPY:DT  copy D(ata) and T(imestamps) for copied files
/COPY:DAT copy D(ata) A(ttributes) and T(imestamps) for copied files (default).
          [Note: If file Data is copied, then file Timestamps are also copied.]  
          [other /COPY: options are available]
/DCOPY:T  copy T(imestamps) for copied folders
/XJ       exclude copying of "Junction-Points"
/ETA      show estimated time remaining while copying which may or may not be helpful
/L        do not actualy copy anything, only show files that "would" be copied
          [useful to "test" your Robocopy command line before actually copying files]
(Many more options are available for Robocopy operation)

For more information about the options for Robocopy see this other post I wrote about Robocopy: https://superuser.com/a/566054/144147, which includes external links to more documentation.

Kevin Fegan

Posted 2012-02-23T00:30:42.443

Reputation: 4 077