7

Copy Files to Android While Preserving Timestamp

 2 years ago
source link: http://siongui.github.io/2021/11/15/copy-file-to-android-preserve-timestamp/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy Files to Android While Preserving Timestamp

November 15, 2021

Recently I bought a Google Pixel XL and tried to copy files to it. I found that the timestamp of the copied files is the time of the creation of the copy, not last modified date in original filesystem. After some googling [1], I found that the only solution to the earlier version of Android is rooting the Android devices.

Luckily enough, The Google Pixel XL can run Android 10 and it is possible to use adb push to keep timestamp because the filesystem is changed from FUSE to SDCardFS.

On Ubuntu system, it is easy to install adb: [3]

$ sudo apt-get install android-tools-adb android-tools-fastboot

Enable USB Debugging on Google Pixel XL [4]. Open a terminal and use USB cable to connect your phone and Ubuntu machine. Allow USB debugging on your phone, in the Ubuntu terminal, we can see the Android device by:

$ adb devices

You can see your phone in the list. Push the files to Android phone by:

$ adb push myfolder /sdcard/Download

After pushing files finished, we can use adb shell to check the files on Android phone:

# Login to Android shell
$ adb shell
# Go to the Download folder
$ cd /sdcard/Download
# See the timestamp of files
$ ls -al

If you are running Android 10 on Google Pixel XL, you can see the timestamp of files is preserved after the push!

Hope this helps those who have the same issue as me.

Tested on: Ubuntu Linux 20.04.


References:

[5]failed to authenticate to <ip> | adb wifi - Stack Overflow


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK