How can I keep file attributes like creation and modified times when copying?

0
0
Asked By CuriousCoder42 On

I'm looking for a way to copy files while ensuring that all their attributes, especially the creation and modified timestamps, are preserved. For instance, if I have a file on an ExFAT drive with a creation time of 12:34:56.78, I want the copied file on the destination drive to maintain that exact timestamp down to the millisecond. Any tips on how to achieve this?

4 Answers

Answered By CopyCat88 On

Try the `cp -a source-file destination-file` command. It should help you maintain the attributes during the copy process, but make sure to check the specific behaviors on different file systems.

Answered By DataKeeper77 On

Keep in mind that preserving creation time can be tricky, especially with filesystems like ext4 or btrfs. There are hacks available, like using `debugfs`, but they can be complicated. Also, I’ve found that copying between ExFAT drives sometimes doesn’t keep the creation time either. Offers no easy solutions depending on the file systems involved.

Answered By FileFreak99 On

You can use the `rsync` command for this purpose. It does a great job of preserving most attributes of files, including timestamps.

Answered By FileMover13 On

If you're focused solely on the timestamps, maybe you should consider moving instead of copying. That way, you won't have to worry about it.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.