Skip to content

Instantly share code, notes, and snippets.

@surajRathi
Last active October 31, 2023 05:39
Show Gist options
  • Save surajRathi/2a78603fcb600400edd07fc518987129 to your computer and use it in GitHub Desktop.
Save surajRathi/2a78603fcb600400edd07fc518987129 to your computer and use it in GitHub Desktop.
Fix timestamps for photos saved via whatsapp, to have them show up correctly in Google Photos. Enable backup of both of the Cleansapp folders in Google Photos.
#! /usr/bin/sh
# For Whatsapp saved photos.
adb pull -a -z zstd /storage/emulated/0/Pictures/Whatsapp ./
cd Whatsapp
exiftool '-FileCreateDate<${Filename; s/IMG-([0-9]{4})([0-9]{2})([0-9]{2})-.*\.jpg/$1:$2:$3 12:00:00+5:30/}' '-Exif:DateTimeOriginal<${Filename; s/IMG-([0-9]{4})([0-9]{2})([0-9]{2})-.*\.jpg/$1:$2:$3 12:00:00+5:30/}' *.jpg
cd ..
mv Whatsapp Cleansapp
adb push -z zstd ./Cleansapp /storage/emulated/0/Pictures/
rm -r Cleansapp
# For Whatsapp Videos
adb shell
cd /storage/emulated/0/Movies/Whatsapp
for file in `ls`; do touch -amt "$(echo $file | cut -d '-' -f 2)1200" $file; done
cd ..
mv Whatsapp/* Cleansapp/
@srathi-monarch
Copy link

May want to change the exiftool command to use AllDates

exiftool -overwrite_original -r -P "-AllDates<FileModifyDate" "your/output/folder/ALL_PHOTOS/"

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