Skip to content

Instantly share code, notes, and snippets.

@heisvoid
Created October 31, 2019 10:16
Show Gist options
  • Save heisvoid/fd679fcfab3d11ecc5bdbd37b8da2294 to your computer and use it in GitHub Desktop.
Save heisvoid/fd679fcfab3d11ecc5bdbd37b8da2294 to your computer and use it in GitHub Desktop.
Edit the metadata 'Create Date' of Google photos Takeout files
#!/bin/sh
# Edit the metadata 'Create Date'
files=$(mktemp)
find "$1" -type f -iname "*.jpg" > $files
while IFS= read -r f
do
create_date=$(exiftool -CreateDate "$f" | cut -d ":" -f 2)
if [ ! -z "$create_date" ] && [ " 0000" != "$create_date" ]; then
continue
fi
time_stamp=$(exiftool -TimeStamp "$f" | cut -d ":" -f 2)
if [ ! -z "$time_stamp" ] && [ " 0000" != "$time_stamp" ]; then
continue
fi
ts=$(jq -r .photoTakenTime.timestamp "$f.json")
create_date=$(TZ="UTC" date --date="@$ts" "+%Y:%m:%d %H:%M:%S")
exiftool -CreateDate="$create_date" "$f"
done < "$files"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment