Skip to content

Instantly share code, notes, and snippets.

@TiiFuchs
Created June 5, 2019 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TiiFuchs/4497c2e16ea6af63ab69446f3d08c543 to your computer and use it in GitHub Desktop.
Save TiiFuchs/4497c2e16ea6af63ab69446f3d08c543 to your computer and use it in GitHub Desktop.
Parses the datetime from exported Telegram photos and reinserts them as EXIF recording date.
#!/bin/bash
folder=$(realpath $1)
if [[ ! -d $folder ]]; then
echo "No valid folder."
exit 1
fi
# Delete Thumbnails
find $folder -name "*_thumb*" -delete
for filepath in $folder/*.jpg; do
filename=$(basename $filepath)
time=$(echo $filename | sed -E 's/photo_[0-9]+@([0-9]+)-([0-9]+)-([0-9]+)_([0-9]+)-([0-9]+)-([0-9]+).jpg/\3:\2:\1 \4:\5:\6/')
echo $filename = $time
exiftool -overwrite_original "-DateTimeOriginal=$time" $filepath
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment