Skip to content

Instantly share code, notes, and snippets.

@Wonicon
Created December 20, 2019 09:51
Show Gist options
  • Save Wonicon/10fbcc115a74a6f1176789fa27c0a964 to your computer and use it in GitHub Desktop.
Save Wonicon/10fbcc115a74a6f1176789fa27c0a964 to your computer and use it in GitHub Desktop.
Recover timestamp for images taken out from Google photos
function change_ts
set json $argv[1]
set img $argv[2]
set ts_epoch (jq '.photoTakenTime.timestamp' $json | grep --only-matching "[0-9]\+")
set title (jq '.title' $json | sed 's/^"\(.*\)"$/\1/')
set ts_fmt (date --utc --date=@$ts_epoch)
cp $img "../out/$title"
touch --date="$ts_fmt" "../out/$title"
end
# Under Google Photos directory
set json_list (ls */*.json)
set img_list (ls */* | grep -v json)
set i 0
set len (ls */*.json | wc -l)
while [ $i -lt $len ]
change_ts $json_list[$i] $img_list[$i]
set i (expr $i + 1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment