robocopy - when does it delete files from destination?

I want to overwrite older files in the destination but not delete files which are only present in the destination.

From I understood that /XO might do exactly that but I also understood that it is possible to delete files from the destination (if they have no counterpart in the source). When exactly does this second behaviour (which I want to avoid) occur?

1

1 Answer

When you use either one of two options:

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

example:

  • robocopy /PURGE c:\source d:\destination
  • robocopy /MIR c:\source d:\destination

Then you will delete files in the destination if they do not exist in the source.

Robocopy will also default to "By default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes."

I would also suggest that you look into:

  • /COPY:copyflag[s] : What to COPY (default is /COPY:DAT) (copyflags : D=Data, A=Attributes, T=Timestamps S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

example:

  • robocopy /COPY:DAT c:\source d:\destination

That will make sure you get the same timestamps for the files that will be copied.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like