Google Photos Takeout

Recently my wife found that she was nearly at capacity of the free storage on Google Photos. We decided that we’d replace it with the Nextcloud instance I run, so photos she takes are now being uploaded to Nextcloud and then transferred to our NAS.

We wanted the existing photos from Google to be accessible from the same place, so we did a Google Takeout.

Once we’d got the photos, I needed to parse the metadata that google stored about each one, so they could be transferred to the correct Folder.

Bash script for scraping metadata and moving photos to correct location

find . -name '*json' | while read line; do
echo "----------------------------------------"
    echo "Processing file '$line'"
    real="${line%.*}"

echo "Actual file '$real'"
#temp=$(echo $line)
#echo $temp
#jq "." "$line"
#echo 'running jq jq .googlePhotosOrigin.mobileUpload.deviceFolder.localFolderName $(line)'
folder=$(jq -r .googlePhotosOrigin.mobileUpload.deviceFolder.localFolderName "$line")
timestamp=$(jq -r .photoTakenTime.timestamp "$line")
echo "timestamp is $timestamp"
year=$(date -r $timestamp +'%Y')
month=$(date -r $timestamp +'%m')
echo "result is $folder"
echo "taken $year $month"
nulstr="null"
empstr=""
if [ "$folder" == "$nulstr" ]; then
folder=Camera
fi
if [ "$folder" == "$empstr" ]; then
folder=Camera
fi
Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *