How to preserve time stamps?

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

Post Reply
officiallyme
Junior Member
Junior Member
Posts: 7
Joined: 2017-09-22, 08:36 UTC

How to preserve time stamps?

Post by *officiallyme »

Hi,
I have a problem, obviously.

I had to factory reset my phone, including wiping my internal memory.

Now I would like to copy my files (photos, music etc.) back to my card using Total Commander.
However, everything I copy from my NFS server to my phone automatically gets the time stamp of the copy process.

Now for a lot of files this would not matter, but pictures are sorted by date. So they are all messed up now. And since a lot do not have EXIF data, I will need to preserve the original time stamps.

Does anybody know how to do this?
I also tried copying a zip of the files to my phone and then extracting with Total Commander. Same problem. Time stamp is th time of extraction.

I hope someone can help me out here :-(
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

This is a very longtime Android bug: It's not possible to set/copy the timestamp of files on Android due to missing permissions of the user to set them. Only the root user is allowed to set/copy the timestamp.

Here are the relevant bug reports in the Android bug tracker:

File setLastModified always returns false
https://code.google.com/p/android/issues/detail?id=1992

setLastModified() always fails on Xoom unless running as root
https://code.google.com/p/android/issues/detail?id=18624

File.setLastModified() always returns false on Samsung Galaxy Nexus
https://code.google.com/p/android/issues/detail?id=25460
Author of Total Commander
https://www.ghisler.com
officiallyme
Junior Member
Junior Member
Posts: 7
Joined: 2017-09-22, 08:36 UTC

Post by *officiallyme »

So there is absolutely no way to get around this? No FTP, SMB, NFS file transfer? No zip, rar, tar.gz or anything?
tag
Junior Member
Junior Member
Posts: 61
Joined: 2014-12-11, 11:03 UTC

Post by *tag »

If you don't want to root your phone, you need to use external media.

You may put your external SD into a card reader and write it using a computer.

You may use some Samba or FTP file server, or whatever cloud service as copy destination, where you manage your files.

But if you want to have the files on the internal SD of your device afterwards, you will have to wait for Android Oreo where this is fixed (by using sdcardFS instead of FUSE) - or root your device.
officiallyme
Junior Member
Junior Member
Posts: 7
Joined: 2017-09-22, 08:36 UTC

Post by *officiallyme »

Unfortunately rooting means triggering KNOX. And there will be no Oreo on Samsung S6 :-(

Maybe I can somehow get them to my phone as pseudo root by using ODIN to copy the data? I started a thread on XDA (will add URL tomorrow as I am still a restricted user). But same username on XDA, in case someone wants to look or contribute :-)

By the way, I am using a Samsung Galaxy S6 edge, so no memory card slots, so no external memory -.-
officiallyme
Junior Member
Junior Member
Posts: 7
Joined: 2017-09-22, 08:36 UTC

Post by *officiallyme »

Hi,
I tried using a USB drive now. Copied the data to the USB drive, connected it to my phone and copied internally. But same result :-(

So I guess if I were able to use a memory card inside my phone it wouldn't work anyway.
tag
Junior Member
Junior Member
Posts: 61
Joined: 2014-12-11, 11:03 UTC

Post by *tag »

My idea was not that you take Samba, sd card or something as source for copying to internal. The source does not matter. If destination is internal you can't set timestamp. My idea was that you keep the files on sd card samba whatever and manage it there, without copying them to internal ... ;)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

You could take the memory card out and put the files on it with Windows, Linux or MacOS. They don't have the bug Android has with timestamps...
Author of Total Commander
https://www.ghisler.com
officiallyme
Junior Member
Junior Member
Posts: 7
Joined: 2017-09-22, 08:36 UTC

Post by *officiallyme »

Ah, sorry @tag, I misunderstood.

The problem, as I said, is that the S6 edge does not support sd cards.

So, if I were to root my device, this issue would be obsolete? Would the files then be copied with the correct timestamp or would I have to manually alter the timestamps of the files afterwards?

Is there a way to make Total Commander copy the files one by one based on the timestamp of the original file? That way the sort order would remain in tact even though the absolute date would be wrong.
tag
Junior Member
Junior Member
Posts: 61
Joined: 2014-12-11, 11:03 UTC

Post by *tag »

If you would have read what I wrote and followed the link you would know the answer ...

Using TC you usually will be fine - as long as you use TC for the copy of the file where you want to keep date and TC has root rights.

Although i now posted a short summary, it will help if you understand the issue. Please read my link.
officiallyme
Junior Member
Junior Member
Posts: 7
Joined: 2017-09-22, 08:36 UTC

Post by *officiallyme »

Hi,
I read your links. But I did not re-read to check if TC would preserve the timestamps once rooted. Sorry.

But right now I am trying to maybe circumvent the problem by copying with some kind of linux script.
But I haven't quite gotten it right yet.

Code: Select all

cp (ls -1t) ./destination
should copy in the right order. But I would like to ensure the timestamp is one second apart, so I need to add a sleep function. But I am not sure how to best do it because it needs to sleep after each file and not at the end :D

If that then also does not work properly, then I will root my phone :x
tag
Junior Member
Junior Member
Posts: 61
Joined: 2014-12-11, 11:03 UTC

Post by *tag »

You may want to search for "bash for files" in Google to get the right syntax for your idea. If you only need the order it could work.

My recommendation would be considering to get some device which is better to root and can use external SD. Since I had a Galaxy S3, I don't like Samsung devices anymore. My opinion: Touchwiz is a bad idea and sometimes buggy implemented, and that Knox thing doesn't make things better.
officiallyme
Junior Member
Junior Member
Posts: 7
Joined: 2017-09-22, 08:36 UTC

Post by *officiallyme »

I never liked the S3.
I started with an S2 and loved it. Really loved it. And it had a great community working on it at XDA anf other sites.
From there I went straight to the S6 edge, because 3, 4 and 5 were all boring. S6 edge was the first interesting new model.

I never used Touchwiz but went straigth for thr Nova Launcher. And on the S2 I had custom ROMs lile Resurrection Remix. But since I use mobile payment, rooting is a bit tricky.

Anyway, I found that using a terminal on my S6 and a usb stick hooked up to it, I can bash copy the files. It works with the command stated above. But it seems they are not 100% in the right order. So I need to figure out the sleep/delay issue.

I will of course report back. But I am still waiting for my registration to clear in the Linux forum I registered to.
anmac1789
Junior Member
Junior Member
Posts: 36
Joined: 2020-11-30, 01:33 UTC

Re: How to preserve time stamps?

Post by *anmac1789 »

I know this topic is old but I have a galaxy s8 with sdcardFS running android 9 pie. I don't know how to preserve folders date and timestamps when copying to PC. Do you have any luck ?
Post Reply