Skip to content

Instantly share code, notes, and snippets.

@olaurendeau
Created February 23, 2024 09:03
Show Gist options
  • Select an option

  • Save olaurendeau/52afa5b138be8d4da0e2ecca2868e372 to your computer and use it in GitHub Desktop.

Select an option

Save olaurendeau/52afa5b138be8d4da0e2ecca2868e372 to your computer and use it in GitHub Desktop.
Reorder google photos by their creation date, based on an export from google Takeout

OS

Should work on MacOS & linux

Usage

1 - Download the photos with google takeout

https://support.google.com/accounts/answer/9666875?hl=en

2 - Setup the tool

Download the google-takeout-photo-renamer.sh file below

Open a terminal and move to the folder where the google-takeout-photo-renamer.sh file is (for me in ~/Downloads) cd ~/Downloads

Allow execution of this file chmod +x google-takeout-photo-renamer.sh

3 - Reorder your photos !

Let's assume that your Photos are in a ~/Downloads/Takeout/Google\ Photos/Album folder

Then execute the script by running ./google-takeout-photo-renamer.sh ~/Downloads/Takeout/Google\ Photos/Album

You should see your reordered photos in the folder ~/Downloads/Takeout/Google\ Photos/Album/output

#!/bin/bash
folder=$1
echo ">>> processing folder $folder"
for metadataFilename in "$folder"/*.json; do
photoFilename=`echo $metadataFilename | sed s/.json//g`;
if [ -f "$photoFilename" ]; then
echo ">>>>>> processing $photoFilename"
timestamp=`jq .photoTakenTime.timestamp "$metadataFilename" | sed s/\"//g`;
echo $timestamp
photoFilenameWithoutFolder=`basename "$photoFilename"`
echo $photoFilenameWithoutFolder
newPhotoFilename=`echo "${timestamp}_${photoFilenameWithoutFolder}"`
destinationFile=`echo "${folder}/output/${newPhotoFilename}"`
cp "$photoFilename" "$destinationFile"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment