What switches can robocopy use to preserve file and directory times on the target?
Take a look at the options for the /COPY:[copyflags]
and /DCOPY
switches.
As per the ROBOCOPY /?
usage info:
/COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT). (copyflags : D=Data, A=Attributes, T=Timestamps). (S=Security=NTFS ACLs, O=Owner info, U=aUditing info). /DCOPY:T :: COPY Directory Timestamps.
For example:
ROBOCOPY c:\src d:\dest /MIR /COPY:DT /DCOPY:T
Will copy all files and folders and preserve the date and time stamps.
ROBOCOPY c:\src d:\dest /MIR /COPY:DAT /DCOPY:T
Will copy all files and folders and preserve the date & time stamps and file attributes.
There is also another (and I believe deprecated?) switch /TIMFIX
which does much the same as /COPY:DT
but it doesn't fix the time stamps on folders.
These were tested with ROBOCOPY 5.1.10.1027 on Windows 7 x64 Ultimate.
Be aware that the /MIR
switch mirrors the directory that you are copying from; that is, /MIR
will also delete files in the destination folder not found in the source folder. The /MIR
switch is the equivalent of /E
and the /PURGE
switches used together (but with a minor exception).