1

I’m trying to copy all files that are:

  • changed (i.e.: they have a different size in either source or target)
  • Newer or older (they have a newer or older timestamp, i.e.: different date modified or date created). ...but without deleting any items in the target directory. By default, Robocopy would “replace” such files instead of just copying them.

This one I tried replaces files, instead of just copying them: Robocopy “Source folder” “Target folder” /E

Any help much appreciated.

Antonio23249
  • 821
  • 1
  • 8
  • 22
  • 2
    By default existing files are overwritten, that seems to be what you call replace. But you forgot to mention what should happen instead. Save with different name of just ignore? For such complicated situations you may consider learning a script language for generating the list of files to be copied yourself. – Robert Nov 10 '22 at 19:31
  • 1
    I agree with the above comment you should better specify what you want since there can't be 2 files with the same name in the same directory.... – Ricardo Bohner Nov 10 '22 at 19:46
  • You're quite right, I'd like to have them renamed or something similar. Learning a scripting language is going too far for me, I thought robocopy switches may do this, but it seems not to be the case. My aim is to do a differential backup with Robocopy so I don't have to use a third-party tool. Many thanks for your insights. – Antonio23249 Nov 10 '22 at 21:55

1 Answers1

1

it's possible to preserve all timestamps in the copied output, including those of directories and their attributes. for example

Code:

robocopy.exe "<source>" "<destination>" *.* /E /V /R:1 /W:5 /COPY:DATS /DCOPY:DAT

Replace and with the appropriate directory paths, obviously.

. = match all files

/E = Copy sub-directories, including empty ones

/V = Verbose output, showing any skipped files

/R:1 = Number of retries on failed copies (in millions)

/W:5 = Wait time between retries (in seconds)

/COPY:DATS = Copy files' original Data (D), Attributes (A), Timestamps (T), NTFS ACL (S). (Personally I don't normally copy ACL info.)

/DCOPY:DAT = The above but for directories.

also for copying the modified data , may be this link can help

copy changed or newer data