I've downloaded my Google Takeout data and unpacked the archive. I'm mainly interested in the Google Photos content. The images are apparently organizes in the folders representing Google Albums. Many files seem to have a complementary JSON file with meta data. The name of the supplemental file doesn't seem consistent. It always starts with the image filename and ends with .json.
I'm sorting my images by the date & time the picture was taken into a folder structure of year/month/day and each image files is renamed so the filename reflects the date & time it was taken.
I'm using exiftool https://exiftool.org to read the timestamp from the image metainformation itself and then move the files in place. My command line looks like this:
exiftool -r '-FileName<DateTimeOriginal' -d ../Archive/%Y/%m/%d/%Y-%m-%d_%H.%M.%S%%-c_.%%e . > /Users/username/exiftool.log 2>&1
This will find all images in the current directory and below and move them to ../Archive/year/month/day ...
Some of the image files don't seem to contain the EXIF data (or XMP) of when the image was taken. Thus exiftool can't move them as it doesn't find the field DateTimeOriginal in the metadata. For most files Google has put this supplemental JSON document aside the image file which contains the needed information.
All I need is find the respective JSON document, search for the correct timestamp and then use exiftool to update the respective image file metadata.
The plain command line would look something like this:
exiftool -xmp:dateTimeOriginal='2025:04:16 19:23:23' filename.jpg
Once the image metadata is updated, I can use the original exiftool call to move the file in place.
Usually I'd solve this with a shell script. But it turns out that the special path and filenames with blanks and parenthesis etc. mess with shell scripting. I tried a bunch of different approaches, but gave up eventually on that path.
Ended up writing this python script to find the respective JSON file and call the exiftool to update the timestamp.
I've first moved out all image files that contain timestamps in there metadata. So one pass of:
exiftool -r '-FileName<DateTimeOriginal' -d ../Archive/%Y/%m/%d/%Y-%m-%d_%H.%M.%S%%-c_.%%e . > /Users/username/exiftool.log 2>&1
Once the good files are out of the way, I update the remaining files metadata with the python script:
find . -type f -iname "*.jpg" -exec python3 /Users/username/Repositories/GoogleTakeoutHelper/process_metadata.py "{}" \;
This will find all .jpg files recursively and call the Python script for each of them. You'll need to either repeat this for other image file endings, or combine into one call of the find command.
find . -type f -iname "*.jpg" -o -iname "*.jpeg" -exec .....
Once all the remaining image files have been update with their metadata I run the original exiftool command again to move the files to their final archive position.