ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: ExifShmexif on April 08, 2021, 02:03:56 AM

Title: Fixing files from Google Photos via Takeout
Post by: ExifShmexif on April 08, 2021, 02:03:56 AM
I received such helpful advice from searching and reading this forum, and the tool itself is amazing, so first of all thank you to all, especially Phil and stargeek. And in some meagre fashion, I wanted to return something by writing up my experience for anyone moving files out of Google Photos via Takeout. Many of the commands here are collected from other posts on this forum, and I'm sure I'll get a few things wrong, but hopefully it'll be helpful.

This will be most useful for anyone who:




Getting images out of Google Photos can be done in two ways.

I'll assume you're doing the first of these. Assuming you selected images from all years in your export, you'll see a set of folders each corresponding to a year. Note: if your collection is larger than 50GB, and you have multiple zips to download and expand I strongly recommend you combine these into one. Takeout doesn't ensure that the media file and associated json are in the same zip, so combining them will fix it.

For any edited file, Takeout also exports both the original and edited files. If you prefer to not have doubles in your collection, you can delete the edits with:

del /s /q *-edited.jpg

You'll also notice that the file creation date for your media has been updated to today. That's probably correct as Takeout sees it, but for media that doesn't have EXIF data with the create date in -- like MP4 files -- your viewing software will probably just use the creation date for ordering, and these files will appear in the wrong place. So, from the Takeout root directory:

exiftool -d "%s" -tagsfromfile %d%f.%e.json "-DateTimeOriginal<PhotoTakenTimeTimestamp" "-FileCreateDate<PhotoTakenTimeTimestamp" "-FileModifyDate<PhotoTakenTimeTimestamp" -overwrite_original -ext mp4 -ext jpg -r .

I've also read that geolocation data may need to be added back to the EXIF data from the JSON file. I didn't find that to be the case for me -- location data seemed intact for the files. But just in case, again from the root:

exiftool -tagsfromfile %d%f.%e.json -description -title "-gpslatitude<GeoDataLatitude" "-gpslatituderef<GeoDataLatitude" "-gpslongitude<GeoDataLongitude" "-gpslongituderef<GeoDataLongitude" ... -ext mp4 -ext jpg -r .

Then, time to get rid of the .json files:

del /s /q *.json

The next part depends on how you want to organise the files. If you want to just dump everything into a directory and let your viewer sort it out -- maybe something like Synology moments -- you're probably done. I personally wanted to organise the files a little better and recreate a directory structure with my best guess of which camera took the image. This has the advantage of helping you identify which photos came from a friend, or any other source.

exiftool "-directory<%d/${model;}" -r .

You also may know that some actions strip exif data, e.g. uploading an image and sending it via some messaging apps or social networks. Additionally, as mentioned, mp4 files generally don't have exif. So if you want to sort further, I found it helpful to sort by image size:

exiftool "-directory<%d/${ImageSize;}" .

.... which helped me identify and group together images that were saved from various sources, like screenshots or movies. (Note that this will save media from the same source in different folders for portrait and landscape, but it's not a big deal to put those together.)

(One final TODO here, is to find a way to edit creation date for files that don't have an associated json file or any exif data, but present the date in the filename, something like 20130602_175206.jpg or 2012-10-16 09.39.07.jpg.)




I hope this has been helpful in some way. Thanks again!
Title: Re: Fixing files from Google Photos via Takeout
Post by: Phil Harvey on April 12, 2021, 08:00:30 AM
Thanks for this write-up.  I'm sure it will be useful for someone else who wants to do this.

- Phil
Title: Re: Fixing files from Google Photos via Takeout
Post by: Nirmitlamed on May 28, 2023, 11:03:25 AM
Wanted to say thank you. It was helpful a lot!