Created
October 31, 2019 10:16
-
-
Save heisvoid/fd679fcfab3d11ecc5bdbd37b8da2294 to your computer and use it in GitHub Desktop.
Edit the metadata 'Create Date' of Google photos Takeout files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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