Windows – Robocopy – how to discard timestamps

robocopywindows

I'm trying to copy some files to a folder where there are already older versions of those files with the robocopy tool. And in order to differentiate versions, I'd like to set the timestamp to "now" in the output folder when the file is copied over.

Basically it would be like copying and "touch"-ing the file.

However, as easy as it looks, it seems that there is no option to do that. I understood that when using the D (data) flag on /COPY, the T (timestamp) flag is automatically added, so the source timestamp is kept.

Is there something I missed in the options? Or is there any other alternative?

Thanks for any help.

Julien.

Best Answer

I don't think Robocopy will work for this. A core part of how Robocopy works is by comparing timestamps and file sizes in the source and destination folders to determine which files need to be copied. So, you can't use Robocopy to update timestamps in the destination to be 'newer' than the timestamps on the source.

Now, I have seen this behavior when pushing files with UNIX permissions to NTFS (or vice versa) but it's not so much an intended behavior as the inability of Robocopy to translate ACLs.

I'm not exactly clear on what you're trying to do, but there's probably quite a few workarounds to get something that works for you. Examples:

  • Have the robocopy script copy files into a directory named based off the date.
  • Capture the time/date to a log file whenever the script runs successfully.