1

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.

13
  • dd? Seriously though, why not simply start with git init and see where that takes you?
    – the
    Commented Aug 3, 2014 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? Commented Aug 4, 2014 at 18:32
  • What about mounting the file systems on one of the Linux boxes?
    – Marcelo
    Commented Aug 4, 2014 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. Commented Aug 4, 2014 at 23:35
  • 1
    Yep. Samba/CIFS can mount windows shares on Linux. For the other Linux box, NFS would be fine.
    – Marcelo
    Commented Aug 8, 2014 at 19:19

4 Answers 4

0

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.

1

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

1

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.

1
  • 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
    Commented Aug 8, 2014 at 16:11
0

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.

3
  • Does ftp preserve file metadata
    – Milind R
    Commented Aug 4, 2014 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
    Commented Aug 5, 2014 at 15:12
  • Yeah, the command is MDTM, which gets the modification time.
    – Milind R
    Commented Aug 8, 2014 at 19:22

You must log in to answer this question.

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