yashsingh1/xdaforums huggingface dataset:
[Android General] sjlouis:
Yes cp -a does not kept timestamps. I've done a "help cp" and with Linux, it seems cp -a is another thing tank keeping timestamps. Then I do it again with cp -p for which Help says cp keeps the timestamps. "cp- p" doesn't keep timestamps. You can see screenshots.

I don't know if it's Busybox or Cyanogen but when I had to use Busybox with AICP 5 and CyanogenMod 12, I had to write "busybox command" as "busybox ls -t".

Christian seems to understand and write well French :) .
[Android General] tag68:
If you just type cp without parameters, you get in the first line the origin of the command. At least if it is BusyBox, it is mentioned there.

In Switzerland this is quite common. Parts of Switzerland have French as main language.

But as cp does not work, I guess you have to find out if it's CyanogenMod or AICP which does the modification which prevents timestamp change with root, and Christian can't help much ...

If someone confirms the problem exists with CyanogenMod (my guess), I will add it to the guide.
[Android General] sjlouis:
Yes I know that Swiss people can speak German, French and Italian bit I know more Belgians and not all speak French ;) .

I've tried "cp" and I haven't see any information about "busybox".

I shall try to install Cyanogenmod to see if the problem comes from CyanogenMod, what I fear.
[Android General] tag68:
It may be easier to ask someone who runs CyanogenMod to do a test. I was already looking for the right thread to ask, but didn't find it by now.

You may repeat the test with the cp from busybox. Maybe the internal cp is causing the problem here. I think is not not probable that CyanogenMod changes the working principle of FUSE. It is more likely that

1. CyanogenMod removed the setting of timestamp which doesn't work anyway (maybe they did not test with root)

2. TC has no root rights

3. SManager internally calls cp - which does not work fine according to my assumption.

Many guesses. If I'm right, this increases the probability that your problem is solvable. Did you test with X-Plore also (but of course it also may call cp)?
[Android General] sjlouis:
I've installed CyanogenMod 13 and the first time it takes the previous system and user data and parameters, then TC didn't keep time stamps. I installed again CM 13 after formatting system and user data, then TC kept timestamps. There is only a little bug, from external sdcard to internal memory, I have to refresh the screen to see the creation date otherwise I see the date and hour of the "now" moment.

Ok, I have to reinstall all my rom.

I haven't tried Busybox but Toybox cp and it didn't work but as I said on ghisler.ch, rsync keeps timestamps.

I shall update ghisler tomorrow ;) .
[Android General] sjlouis:
I've reinstalled Busybox in /sbin as another guy asks me and I add "cp" and "mv" from Busybox. They keeps timestamps while while standard and toybox commands don't do it. It's a good thing for my scripts :) .

And now I can see /sbin with TC.
[Android General] PavelBronco:
After my trusty (if somewhat sluggish) S3 Mini has very recently given up the ghost, I've now acquired a Moto G4 Play with Android 6.0.1 and am therefore suffering from this self-same bug, too.

TC does indeed use root powers to preserve the timestamps, however to be honest, I currently still prefer the (slightly older, before they started adding too much unnecessary stuff and three (!) background services) version of ES File Explorer I'm currently using.

Luckily it seems like there might be a fifth workaround method (at least on some phones, I've no idea how universal this method is): Using the direct paths to the file systems concerned instead of the default FUSE-plagued mountpoints provided under /storage.

So if I direct ES File Explorer to use /data/media/0 instead of /storage/emulated/0, as well as /mnt/media_rw/<sd card serial number> instead of /storage/<sd card serial number>, it looks like I can copy and move files to my heart's content without destroying the timestamps.

To make accessing those locations slightly more comfortable, I've also installed Universal init.d to run these two commands after boot, since symlinks added under /storage don't seem to survive a reboot:

ln -s /data/media/0/ /storage/sd[B]C[/B]ard0
ln -s /mnt/media_rw/<sd card serial number>/ /storage/extSdCard

It also seems mandatory not to name the symlink sdcard0 (as it used to be called on my old phone), since in that case it seems there is still some special logic for that specific filename which kicks in and redirects the access to the FUSE mountpoint, which

a) of course defeats the original objective of preserving the timestamp

b) doesn't really seem to work anyway - it looked like I could copy files through that symlink, but in any case not open them

Using sdCard0 for the symlink on the other hand works fine - at least one good thing about Linux being case-sensitive about file names.
[Android General] sjlouis:
Interesting :) .
[Android General] PavelBronco:
One caveat with my workaround seems to be that for new files/folders created on the internal storage, at least ES File Explorer doesn't set the correct permissions, so you have to run chown and chmod afterwards to fix up the file permissions, e.g. something like

chown -R 1023:1023 /storage/sdCard0/
chmod -R ug=rw,o=r /storage/sdCard0/
chmod -R a+X /storage/sdCard0

In any case the good news seems to be that this might have been finally fixed by Google :victory:
[Android General] tag68:
I don't like to take you the joy, but AOSP is not Google.

Edit: AOSP is Google. I had some brain mismatch. Thank you for the hint!
[Android General] wilflare:
seems like Google may be finally fixing this

https://code.google.com/p/android/issues/detail?id=18624
[Android General] Stefan2142:
My Fix

I too wandered how to solve this problem when I bought new phone and after some months I finally got it.

This works for preserving attributes and timestamps for both files and folders. Note that your device has to be rooted. Also, I tested this on Nexus4 Lollipop 5.0.1, but should probably work on Marshmallow too

Step one, get Robocopy, a tool from Microsoft.

Step two, install Samba File Sharing for Android on your phone and configure it properly so you can see your phone in MyComputer -> Networks

Step three, modify this command to suit your needs:

"ROBOCOPY c:\src d:\dest /MIR /COPY:DAT /DCOPY:T"

A big note on that command: argument '/MIR' is really important because if say, your destination is 'D:\', that command will copy everything from the 'C:\src' to 'D:\' but it will delete everything in the 'D:\' that is not content from the 'C:\src'. So, always create separate folder for copying. You can use that command without '/MIR', but I am not sure if will it maintain attributes for directories too

Link about some examples and commands: https://www.windows-commandline.com/robocopy-switches-syntax-examples/
[Android General] sjlouis:
I've installed AICP 6.0.1 (Marshmallow) in October and I've noticed some problems : Total Commander didn't keep timestamps if I copy files on an USB key and Script Manager didn't see the content of the USB Key.

This week-end, I've installed AICP 7.1.1 (Nougat) and there were the same problems. Worse, SM doesn't see the USB key, which is annoying because I can't use scripts to access the key.

AICP is based on Cyanogenmod. Haver you the same problems with other roms?
[Android General] tag68:
Never used anything other than stock ROM on my devices. I'd like to have a look on CM but doubt I want to keep it - and for that experiment the time is too valuable for me to try it.

Starting with Android 8 sdcardfs may come and timestamp and setting attributes without root will revive I hope. This should influence all other ROMs too.
[Android General] sjlouis:
With your stock rom, have you the same problems than me for timestamps between phone and USB key?

And do you HOPE Google allows again to write simply on SD card? Or have you read something that explains Google intend to restore the writing rights?

Cyanogenmod is dead, I shall try with its son Lineage OS : https://download.lineageos.org/

I also haven't a lot of time, that's why I don't try a lot of roms and I've waited before installing the new version of AICP ;) .
[Android General] Sr. Zé Alguém:
Hello [MENTION=6192363]tag68[/MENTION] If possible, could you please add MiXplorer to the list of apps that can keep timestamps of files? MiXplorer is an excellent file manager available only here at XDA. It supports keeping timestamps of files in rooted devices since v6.11.2.BETA_B1701251 when the option "Last modified time" is enabled inside its Settings.
[Android General] tag68:
The setting exists, but for me it did not work: Installed it. Set the setting for copy timestamp using root. Tried to copy from internal storage to sd. Should select sd card to grant access, but got an empty window. Copied a file from root dir of internal storage (on my Moto Z Play with marshmallow using f2fs) to a folder in internal storage. MiXplorer asked for root permission, but the file got timestamp "now".

Does it work for you?
[Android General] Sr. Zé Alguém:
Atm, I don't have a rooted phone to test on. I remember when it was implemented it worked at least for internal storage. Btw, did you refreshed the tab after copying, right? Nonetheless, it may a bug with sd cards, I'll mention it in the topic, so the dev can take a look into that when possible. If you have time, it would be useful if you could post a Log file capturing the moment where it fails; how to take a log is in the MiXplorer FAQ.

Thanks.
[Android General] tag68:
I am puzzled! touch -t does not accept seconds when using the toybox version of touch on my Moto Z Play (see also thread MiXplorer, linked in post above):

touch -t 201703220547.16 "/storage/emulated/0/t/A/2"

This is the line that gives bad "201703220547.16"

touch -t 201703220547 "/storage/emulated/0/t/A/2"

This command works fine!

And the help:

~$ touch --help

usage: touch [-amch] [-d DATE] [-t TIME] [-r FILE] FILE...

Update the access and modification times of each FILE to the current time.

-a change access time

-m change modification time

-c don't create file

-h change symlink

-d set time to DATE (in YYYY-MM-DDThh:mm:SS[.frac][tz] format)-t set time to TIME (in [[CC]YY]MMDDhhmm[.ss][frac] format)

-r set time same as reference FILE

When calling Magisk BusyBox version of touch it runs fine with seconds!

Anyone an idea how to configure something or change the line so that toybox touch accepts seconds?
[Android General] Metachemix1:
I just found out after hours of googling and testing.. The solution!

Requirements:

- root in order to preserve timestamps on restore

- Rsync server, PC with linux or Windows with Cygwin, or a NAS that supports RSync

- busybox

-Terminal emulator or adb shell

- Mixplorer or any other file Explorer would work if it supports samba connections

Steps performed

- Shared folder on NAS called backup

- Terminal Emulator shell running

- Mixplorer with local and NAS folders open

NOTE: This will restore ALL modified timestamps for files and folders!

Android to nas requires normal or su shell

rsync -avRPh localsourcefolder rsync://rsync@nas:873/Backup

Nas to android requires su shell

rsync -avRPh rsync://rsync@nas:873/Backup/ localbackupfolder

The rsync command options used are

av : Archives the files and keeps the timestamps

R: keeps root folder including complete structure

P: shows progress

h: makes output human readable

Good luck to you all! I hope this information is helpful :cool:

Tested on OnePlus One CyanogenOS 6.0.1 with root access enabled.

Cheers!
[Android General] tag68:
Found the source of toybox touch, need to have a look. Didn't see the problem in first place. And now trying touch does not even do what I want just ignoring the timestamp. Will have a look later.
[Android General] tag68:
Toybox touch seems to be just broken. Only call working fine is touch -r <source> <dest>, which copies timestamp from one file to the other. Giving any time using -t or -d didn't work for me. It always touches using current timestamp.
[Android General] hysssop:
Total Commander and Peazip keep change date

Hi. Yesterday and today I had trouble copying data from the internal sdcard of my Acer S510 with Android 4.4.2 to external sdcards.

The modify dates of the folders and of the files were replaced by the current date.

My working solution; :laugh:

*. On Android: zip via Total Commander v9.

*. Copy zipfile to Windows (10-64).

*. On Windows; Unzip with Peazip 6.4.1.

*. Use Robocopy options COPY ALL and DCOPY DAT to copy between Windows folders.

Hope I am of some help. Bye from Tilburg in the south of The Netherlands!
[Android General] brpqzme:
Just curious - has this been fixed on AOSP 8.0?

I copied files from my 7.x Pixel to PC and lost all timestamps (didn't realise it was a 2-way thing)
[Android General] tag68:
Don't have an Oreo device by now and did not read confirmation. But it should. Hope you will get some comment by someone who tried ;)

It is no 2-way thing. Copying to PC is possible keeping timestamp, and usually works fine. What were you using to copy the data?
[Android General] brpqzme:
Hm that's odd. All of the photos I copied over - using standard MTP in Windows - and the Date created/modified/taken stamps all got changed (Pixel on 8.0 to Windows 8.1). I tried a standard MTP copy of a file and it didn't keep the attributes (I assume the F2FS change happens automatically upon updating to 8..). Maybe it's just me, I'll give it a shot on the 8.1 update as well and see if it's been fixed
[Android General] tag68:
I have no idea what a standard MTP copy on Windows is. You mean windows explorer? I don't know how it behaves.

Please do following:

1. Create a Samba share somewhere (windows file sharing)

2. Install Total Commander and lan plugin for tc in Android

3. Copy some file using Total Commander for Android to that share

I did that test after revoking superuser for Total Commander. My Samba share was on the router (AVM Fritzbox 7490), but that should not matter. Attributes were copied.
[Android General] brpqzme:
Hm, so I tried something before reading your post, but let me know if you still want me to try the Samba method and I will :)

So I used SSH to transfer the files between PC-Phone. From my PC onto the phone. The files that had attributes already kept those attributes, so that's. good.

Sadly, the DCIM videos I copied earlier (from Pixel to PC) had their DATE CREATED and DATE MODIFIED attributes changed to the time of the file transfre (and date taken is blank for Videos). So consequently the only timestamps available for those videos were changed to the transfer-time. And I can't redo the test since I formatted the Pixel after backing up to HD. This was a transfer on a Pixel running 8.0 to a Windows PC over USB (MTP) in Explorer.
[Android General] tag68:
I do not want you to do the test. I know it works fine. You probably want to do the test to know how to do it when you need it, and know that your system does not behave different - using Windows you never know what happens ;)

Photos and videos usually contain some tag which tells the creation date. Some programs can rename the file or set the file timestamp according to the tags. You may look for such a tool. (For Apple Macintosh the one which I am using is called "ExifRenamer")

Edit: Short note as hint when searching. EXIF is a standard for photos only, but the software I am using also deals with the tags which are contained in video media container. You may need to search for different keywords, if you find software dealing only with photos. You may want to avoid exif as keyword and google more like "tag video rename windows" or similar.
[Android General] brpqzme:
Haha ah thanks, I thought you wanted me to experiment and report back to you :)

Thanks for the advice so far - I'll try to look for an ExifRenamer Windows equivalent. So do Videos have EXIF (date taken) tags? The reason I ask is cos the DCIM folder I copied, the photos have EXIF for DATE TAKEN (preserved if transferred over SSH) and CREATED, and MODIFIED (both of these are changed to date of transfer when I copied it from my Pixel 8.0 to Windows... - is that 'expected' behaviour from F2FS i.e. TAKEN tags are kept, but MODIFIED/CREATED are updated?)
[Android General] tag68:
They have tags. EXIF is a photo thing. But it is similar.

If you like command line, you may have a look at exiftool. It should be capable of dealing with video, and there should exist a binary for Windows. Afaik it is quite mighty. Did use it one or two times about a year ago, at that time due photos only.

Think about it. When was the file created? At the time of the copy. When was it last changed? If you did not change after making the photo, it was last modified when taken. Copy is no modification.

This is no f2fs thing. It is a filesystem-management-under-Unix-thing.
[Android General] smart_thingup:
Copying from USB OTG to phone with total commander solve the problem. The date created will still the same after copying.
[Android General] tag68:
You should let the people read the OP. Your hint is not helpful at all. You don't mention which OS you are using and if you gave TC root right. On Android newer than 4 and older than 8 it only works if TC has root rights - that's why I wrote my guide.
[Android General] smart_thingup:
I'm sorry.

Yes you are right. I do have root right with my MIUI.eu ROM.

Because I just know after open this thread that my issue with date created is can be solve with TC.
[Android General] tag68:
Could please someone who uses Android 8.0 Oreo give me an answer if the issue is fixed?

Test 1: Copy some file using Total Commander without giving it root rights from somewhere (maybe external) to local storage, eg Download folder.

Known result using Android before 8.0: Time and date of the resulting copy is the time of the copy operation

Expected result using Android 8.0: Time and date of the original file is transferred to the copy. I'd like to have this confirmed.

Test 2: Open a terminal. Type

cd Download

echo 1>1

(wait a minute until different time)

cp -a 1 2

ll ?

On my device (pre-Oreo) the file 2 now has a different time. Doing same things, but "su" before cp (and exit afterwards) gives me right date. On Android 8.0 Oreo file 2 now should have same timestamp.

Could please someone using Android 8.0 Oreo give me the answer if my expectation for Oreo is fulfilled for test 1 and 2?
[Android General] kidd604:
I have a stock, non-root Galaxy S7 running Nougat and I took a lot of photos that were saved to the internal storage. When I added a micro SD card later on and wanted to transfer the pictures from the internal storage to the micro SD card, I tried using Gallery and My Files (Samsung's stock file manager), but none of them would preserve the file timestamps. I also tried copying the pictures from internal storage to my PC via MTP but that did not work either.

After some Googling, I came up with a not-so-convenient workaround: use ADB to pull the pictures off internal storage to a PC, then copy/move the pictures to the micro SD card on the PC. The latest version of ADB included in the platform tools from Google (https://developer.android.com/studio/releases/platform-tools.html#download) includes an option (-a) for pull to preserve timestamps. For example:

adb pull -a /sdcard/DCIM .

Too bad it does not have an option to preserve timestamps for pushing :p This method works for any files you can access, not just pictures. I used this to make a backup of my WhatsApp folder too.
[Android General] The7Suggester:
Yes, ES File Explorer also has this Problem.

I use X-Plore, this preserves all the DCIM/picture file time stamps

X-Plore also supports most cloud based file storage and also has SAMBA network support
[Android General] cafedeluv:
I tried Test 1 on Samsung S8 running Android Oreo.

The result: time stamp of the files tranfered were maintained. Unfortunately, time stamp of folders are that of the copy operation.
[Android General] SGH-i200:
adb pull has preserve timestamps option / QuickPic 'correct timestamp' feature

Thanks for the mentioning of the pull option! I'm using the MyPhoneExplorer desktop application for Windows (it reads the capture date from the EXIF data to set timestamp) to backup the pictures with correct timestamp to my Windows desktop.

'Not-so-convenient' way of preserving timestamp, when moving files from Internal to mSD:

Did you try the Android migration option, when you added the mSD? I hope this Android feature will preserve the timestamps!? I'm use the 'correct timestamp' feature of the QuickPic app to fix the dates of the copied pictures.
[Android General] tag68:
Using an external device (eg computer) to write on a storage which to be used later by Android of course is fine. Will add it as workaround to the guide when having a bit more time.
[Android General] kidd604:
No, I haven't tried that option. My micro SD card is busted, so I'm stuck with using internal flash for now. I'll give it a try once I get my hands on a new card.
[Android General] SGH-i200:
Yes, I would mount the encrypted 'adopted storage' mode SDCard to a Linux machine: https://nelenkov.blogspot.com/2015/06/decrypting-android-m-adopted-storage.html
[Android General] treysis:
Tried that on my NoteFE, which I updated to Oreo 8.0 last week. Test 1 works, but test 2 doesn't. I think the cp binary doesn't know about -a or doesn't know honor it. However, I can correct the timestamp using "touch". So, it's definitely possible now without root, just not very conveniently. But at least we should now be able to use "File Timestamp" app on non-rooted phones. But keep in mind, this just applies to this Samsung device, and because of the similarities probably to S7/S7edge as well once they receive Oreo. And S8 probably as well. Might be different for S9 (or more likely S10 with Android P) sometime in the future.

To sum it up, the following operations DO NOT preserve timestamps:

-copy using Samsung's "My Files" on Samsungs phones

-copy to phone using MTP

-copy using MiXplorer

-copy using ADB (actually, I didn't test it)

-copy using cp -a on command line
[Android General] anmac1789@gmail.com:
anyone know if I can keep date and time stamps for normal files such as pdf files, .docx, excel, .m4a voice recorded lecture notes ? thank you
[Android General] tag68:
This one is easy. Don't copy or move them, and the timestamp won't change.

If you need help, you need to tell what you want to do and (in case the topic of this guide is concerned) which OS version and which tools you use. Everything else will be guessing.
[Android General] The7Suggester:
If you talking about moving/copying files then i would i have problems with DCIM files (Camera pictures and video recordings) using apps like ES File Explorer

I have had no problems with files maintaining their original time stamps using

MiX file explorer (here on down XDA)

https://xdaforums.com/showthread.php?t=1523691

or

X-plore (on Google Play Store)

Help this helps :)
[Android General] tag68:
A suggestion for ES file explorer in my opinion never helps. It's evil.

You don't know if the conditions for keeping timestamps are met. Oreo? Root? Also you don't tell anything about your environment and why you have the right to set timestamps.

If your posting helps in any way, it is by accident.

BTW the file manager usually don't treat pictures in another way than other h files when copying or moving.

Helpful would have been the hint to read the OP where all these things are explained - although this should be needless to say ;)