Similar to but more demanding than this question : How to copy files while not modifying the file creation times at all?

I want to copy files between computers without the "Modified" and "Created" dates being messed with.

The purpose is to compare diffs of some project code in 3 different computers which I had managed to sync when I was working on them. But I worked on only one machine at a time, and now I don't remember which was the most updated one. It's a mess, and I want to unify the copies (and hopefully put it under version control) once and for all.

So when I use diff tools, knowing file modification dates can help me understand and merge changes.

2 of the 3 computers are linux, and 1 is Windows 8.

Any other ways of achieving the above, any best practices in such situations are welcome.

  • dd? Seriously though, why not simply start with git init and see where that takes you? – guaka Aug 3 '14 at 16:18
  • (1) The second answer on the question that you link to is “zip the files”. Why is this not good enough for you? (2) Linux, in general, does not maintain a file created date; so you’re asking for something that doesn’t (and cannot) exist. (3) Why isn’t modification date good enough your purposes? – Scott Aug 4 '14 at 18:32
  • What about mounting the file systems on one of the Linux boxes? – Marcelo Aug 4 '14 at 22:24
  • 1
    I assume, the systems are connected over LAN. In such a case, you can just create a mapped drive ("Tools->Map network drive..." in explorer) and access the files from other system, without actually doing any copy/paste or changes to the attributes. – jjk_charles Aug 4 '14 at 23:35
  • 1
    Yep. Samba/CIFS can mount windows shares on Linux. For the other Linux box, NFS would be fine. – Marcelo Aug 8 '14 at 19:19

On Linux (and other Unix-like OSes), you can copy files to and from a flash drive or from an SMB/FTP server with

cp -p

That should preserve timestamps.

I don't know if timestamps can be preserved when uploading to the server.


Generally there are three attribute for file/folder. Creation, modification and access times. There is no much importantance in access time. In linux Creation time is not not used (and not accessible using standard procedures). So the only important attribute is modification time. While copying data with OS's tool modification time is not changed (at least for linux). If this is not the case you can compress the data before transfer and decompress it at the other end. Generally backup tools preserves all attributes.
If you want to strictly preserve all the attributes you can use the following methods.

cp with option -a a.k.a --archive or --preserve=all
rsync with -t.

These commands are available in linux by default (also downloadable for windows).
If you are not interested in commandline tools use a synchronization tool, that support attribute copy, to copy the data.


If you're not sure what's the best code on the computers, I think it's best to copy all three source directories on one machine, then merge file by file. Merge tools.

Another way would be to create a git repo on a machine, and copy sources from another computer, overwriting the git repo files, or just add them to a new branch, and then use git's merge. For Windows, I prefer Tortoise Git client for doing all the basic versioning stuff.

As for the metadata copy, as suggested by others, you can use rsync -t, cp --preserve=all. For FTP transfers, you can use scp -p.

  • I am certainly planning to use mercurial and version it up, but the date I last messed with one set of code is important in the decision-making involved in merging. – Milind R Aug 8 '14 at 16:11

Between the two Linux computers you can use rsync, it will keep time stamps as they are.
For Windows you can use robocopy to copy the files without changing the time stamps, maybe you can use it to copy the files from an FTP server in your Linux box to Windows.

  • Does ftp preserve file metadata – Milind R Aug 4 '14 at 19:59
  • 1
    Yes, but there is a command need to be supported in the FTP server to preserve time stamps. I don't remember what was the command, but i guess that new versions of FTP servers should support it. Give it a try. – ITProStuff Aug 5 '14 at 15:12
  • Yeah, the command is MDTM, which gets the modification time. – Milind R Aug 8 '14 at 19:22

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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