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.
no answer to the question, but why don't you just use
xcopy
orcopy-item
? it would overwrite all old files in the destination, but not delete files which are only present in the destination. likecopy-item c:\source\* c:\destination -force
– SimonS – 2017-02-23T14:59:04.383