Robocopy to copy only new folders and files

You can add /S for that. You don't need the \E which is for copy empty directories. You won't even need the \XO which is done by the \MAXAGE.

/S :: copy Subdirectories, but not empty ones.

When no files are copied in a directory, the directory is not created on the destination.

robocopy c:\users\valery\documents j:\robocopy /S /MAXAGE:20131030 /XD {directories_to_exclude}

If you don't have directories to exclude you can just use:

robocopy c:\users\valery\documents j:\robocopy /S /MAXAGE:20131030

You can do a robocopy /? for all the help.

 /S :: copy Subdirectories, but not empty ones.
 /E :: copy subdirectories, including Empty ones.
 /XD dirs [dirs]... :: eXclude Directories matching given names/paths.
 /XO :: eXclude Older files.
 /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.

My simple commands that works wonderful is:

RoboCopy.exe  "\\\SourceServer\Folder" "X:\WEB" /copy:datso /mir /fft /r:0 /w:0 /secfix /mt:20 /xo /xf thumbs.db /log+:X:\TON-FS4.log /nc /ns /np /ndl /nfl /tee

Explanation:

  • X:\WEB is my destination folder.
  • Switches:
    • /copy:datso: Specifies the file properties to copy:
      • (d: Data, a: Attributes, t: Time stamps, s: NTFS access control list (ACL), o: Owner information)
    • /mir: Mirrors a directory tree
    • /fft: Assumes FAT file times, important when copying data
    • /r:0: Number of retries on failed
    • /w:0: Wait time between retries 0 seconds
    • /secfix: Fixes file security on all files, even skipped ones
    • /mt:20: Creates 20 threads copies
    • /xo: Excludes older files - if destination file exists and is the same date or newer than the source - don't bother to overwrite it.
    • /xf thumbs.db: Excludes "thumbs.db" files (path) you can use wild characters here (ei: *.mp3)
    • /log+:filename.log: Writes the status output to the specified log file
    • (appends to the existing log file) or to use a new log just /log:filename.log

Not this particular case but I hope that will help someone when they do file servers migration.

Tags:

Command Line