31

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?

2 Answers 2

45

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).

7
  • How do you see your Robo version?
    – Pacerier
    Apr 25, 2015 at 6:46
  • @Pacerier Right-click -> Properties -> Details tab on the executable which is normally located at C:\Windows\System32\Robocopy.exe
    – Kev
    Apr 25, 2015 at 13:15
  • Not possible I'm on UEFI cmd X:\Windows\System32\Robocopy.exe. Is there a cmd way to do it?
    – Pacerier
    Apr 25, 2015 at 15:12
  • @Pacerier - I don't know what you mean by "Not possible I'm on UEFI", can you explain?
    – Kev
    Apr 25, 2015 at 15:25
  • 1
    @Pacerier one of these methods might help: stackoverflow.com/questions/602802/…
    – Kev
    Apr 25, 2015 at 15:30
1

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)

Not the answer you're looking for? Browse other questions tagged or ask your own question.