30

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?

vfclists
  • 1,562
  • 5
  • 20
  • 36

2 Answers2

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

Kev
  • 7,777
  • 17
  • 78
  • 108
  • How do you see your Robo version? – Pacerier Apr 25 '15 at 06:46
  • @Pacerier `Right-click -> Properties -> Details tab` on the executable which is normally located at `C:\Windows\System32\Robocopy.exe` – Kev Apr 25 '15 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 '15 at 15:12
  • @Pacerier - I don't know what you mean by "Not possible I'm on UEFI", can you explain? – Kev Apr 25 '15 at 15:25
  • 1
    @Pacerier one of these methods might help: http://stackoverflow.com/questions/602802/command-line-tool-to-dump-windows-dll-version – Kev Apr 25 '15 at 15:30
  • It means my laptop is currently "UEFI booted". I've got no UI here, just a cmd prompt. – Pacerier Apr 25 '15 at 19:25
  • @Pacerier try asking on superuser.com. I don't have any more time today. – Kev Apr 25 '15 at 19:26
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)

RalfFriedl
  • 3,008
  • 4
  • 12
  • 17
John C
  • 11
  • 1