19

I want to copy a directory tree while preserving timestamps of any file and directory contained therein being copied.

The source directory is on a data DVD (ISO-9660 filesystem). I am copying to an NTFS partition. Copying with Windows Explorer, I see that all folders and files copied have their timestamps set to date and time when the copy operation took place. This is unsatisfactory to me. I want to copy not just file data but also timestamps of regular files and directories.

I googled a bit and recalled using both xcopy and robocopy so I tried both like the following:

robocopy E:\projects C:\Users\me\projects foobar /E /DCOPY:T
xcopy E:\projects C:\Users\me\projects foobar /E /F /K

Robocopy worked for a while and then told me this, interestingly enough:

2016/03/17 20:33:43 ERROR 87 (0x00000057) Time-Stamping Destination Directory c:\Users\me\projects\foobar\baz\mew\
The parameter is incorrect.
Waiting 30 seconds...

Xcopy does not seem to preserve timestamps for subdirectories it copies, and there is no way to tell it to.

I also tried RichCopy from Microsoft TechNet which was touted as all kinds of improvement over Robocopy, and it does not preserve timestamps of directories either and has no options to switch that on.

I have no problems preserving timestamps of files, mind you. All three programs mentioned can do that. Except Explorer, the first thing I tried, but no surprises there, really.

I am on Windows 10 64-bit.

What other program or method can I try to get the kind of behavior I want?

P.S. I also tried Total Commander, because someone on Stack Overflow said it preserves directory timestamps. It doesn't, not for me at least. Also SyncBack could not do it.

3
  • 2
    On Stack Overflow: Move folder between drives on NTFS and preserve timestamps. (Though closed as off-topic, its answers would be appropriate here.)
    – DavidRR
    Dec 23, 2016 at 16:25
  • @amn ... Do you still need a solution to this, because I believe I have one I can write up as an answer but would need to test a bit. It is a PowerShell solution but let me know if interested as I think I could help you get an answer that works and you might even be able to accept. Let me know and I'll be happy to help you get a working solution in place. Aug 8, 2020 at 13:35
  • Appreciate your offer, but it was a sporadic use case, and I can't even recall why it was so important for me to preserve folder timestamps. I wish I could squeeze some more utility out of this question and its answers, but I just can't offer you much more than what's already written. You might still want to invest in a good answer -- there may be others who will benefit from it. Aug 8, 2020 at 14:56

7 Answers 7

9

Make a compressed archive of the data, such as a .zip file. You should then be able to copy that .zip file to any drive and decompress it. All the folders and files should then appear with all their original attributes.

Another option is to make a disk image of the disc and copy that to any drive you want. Whenever you need to view the data just open the disc image up. All your file attributes should be preserved.

2
  • Interesting, thanks. I tried "sending" the folder to a "compressed archive" using ZIP support that is built in to Windows 10, but some of my files have unicode characters in their names, so the process aborted on me with an error. I'll try using WinZIP and see where I end up. Mar 18, 2016 at 11:15
  • What error did you get? Just wondering how you know it's because of the Unicode characters? Another factor could also be how long your file names are? It may also be an idea to try making a compressed file of one folder at a time, in case the issue causing the error was a disc read error due to bad blocks or sectors. Also, if WinZIP doesn't work then definitely try creating a disc image file. It may be worth your while reading this summary of disc formats: msdn.microsoft.com/en-us/library/windows/desktop/…
    – Monomeeth
    Mar 18, 2016 at 11:36
8
cmd>robocopy from to /dcopy:dat

// preserves folder timestamps.

2
  • 1
    not sure why the downvote. this option does work and is part of windows, so no need to use external program
    – panofish
    Jun 2, 2022 at 19:41
  • Exactly what I was looking for. I used to use XXCOPY for this but since it hasn't been maintained in years I was looking for an alternative, and this does the job.
    – Ville
    Jun 6, 2022 at 14:48
4

Total Commander preserves directory timestamps, at least for me, but you need to tell it to do that in options dialog first.

Click ConfigurationOptions, select Copy/Delete (under Operation in listbox on the left), tick Copy date/time of directories (in General Copy+Delete options group on the bottom), click OK.

There might be loads of corner cases where it does not preserve timestamps.  For example, it is said to not preserve timestamps when copying between FAT32 and NTFS.  However, simple ISO9660->NTFS works just fine – just as extracting zip/7z archives.

Also please note that creation timestamp is not preserved.

According to How can I preserve my files' create dates, after copying and pasting to another drive? (on CNET Forums), there is a tool named SafeCopy V2 that could preserve creation timestamp; however, I've never used this myself (Last modified timestamp suffices for me, as it is that timestamp shown by default in Total Commander).

4

I wince at answers that suggest a utility I've never heard of. But FastCopy worked for me. It preserved directory timestamps (both modified and created I think), where @#$%& Windows failed to. Thanks to Touth, Rik for recommending it.

enter image description here

The terminating slash in the destination directory is significant. It copies the source directory instead of its contents.

3

SafeCopy truly copies all files and folders, including the date and time. It is free too! https://www.elwinsoft.com/safecopy-free.html

2
  • SafeCopy doesn’t copy to network shares, only local disks Aug 10, 2020 at 4:43
  • If you run SafeCopyFree (and probably SafeCopy if there is a non-free version) be sure to let it finish the operation before deciding that it doesn't set folder date created correctly. For me it went throught the directory creation and file copy process one item at a time giving each of the items a current timestamp in the date created field and only after all copying had completed did it correctly set the date created attribute one the newly copied items to match the one on the original source items.
    – Night Owl
    Mar 26, 2023 at 0:18
0

In my testing the date modified was changed on folders when the /move parameter was added to the command. If the /move exists, then the folder date modified timestamp becomes the time of the copy. If the /move does not exist, then the folder data modified timestamp is not changed when copied.

1
  • 1
    What command are you talking about?  Please do not respond in comments; edit your answer to make it clearer and more complete. Jun 20, 2019 at 4:39
0

Use the backup function in a tool called xyplorer. Basically when you "backup" a directory of files from drive to another drive, it preserves timestamps for files and directories.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .