Skip to content

Instantly share code, notes, and snippets.

@oripwk
Last active April 28, 2019 13:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oripwk/40fcfe1497b677f86953c2ee811809df to your computer and use it in GitHub Desktop.
Save oripwk/40fcfe1497b677f86953c2ee811809df to your computer and use it in GitHub Desktop.
Restoring WhatsApp files timestamps after Google Drive restore
# when restoring WhatsApp in a new phone, all the timestamps of media files will be reset to today.
# this script will restore the original modification time of the files
cd WhatsApp/Media
while read path; do
f=$(basename "$path");
touch -m -d "${f:4:4}-${f:8:2}-${f:10:2}T12:00:00z" "${path}";
done < <(find . -regextype posix-extended -regex ".*/[[:alpha:]]{3}-[[:digit:]]{8}-.*")
@dowhiletrue
Copy link

Hi @oripwk
Did you run this script on a mounted sd card?

I'm asking this because my WhatsApp folder is accessible on the phone only using either adb shell or MTP. MTP does not support changing the file date and the shell on the phone is incompatible with the syntax of the script and does not have regex support for find.

@oripwk
Copy link
Author

oripwk commented Apr 28, 2019

Hi,

It was a long time ago. But if I remember correctly, I copied the whole directory to my laptop, ran the script, and then copied it back to the Android phone using ADB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment