After using robocopy to copy files to a new drive I realized that all the file and directory creation times and been reset to the time of copying.
Are there some switches to make robocopy keep the original files times?
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).
I use this at work. Safer than using the /MIR switch which can overwrite or delete data. This will copy timestamps for folders and files.
robocopy G:\users\username F:\Users\username /COPYALL /E /dcopy:T /SECFIX
/E copies empty folders (remove if not needed)
/SECFIX copies the NTFS permissions (remove if not needed)
/XO can be added to exclude older (ie if doing a true-up for a folder migration)