When photos and videos are backed up from Google Photos using Google Takeout, the exif metadata properties are often not correct. The DateTimeOriginal
, FileCreateDate
, and FileModifyDate
end up being the timestamp when the files were downloaded, and not the actual timestamp of when the photo/video was created. Google provides us with a JSON file for each photo/video which contains the original metadata (including the correct date/timestamp properties), which we can use to correct the metadata of the downloaded files.
This script intends to provide an easy way to fix all the metadata issues related the Google Takeout files.
This script assumes you use the following process to perform your Google Photos backup:
- Download your Google Takeout output
- Unzip it
- (Optional) Download your Google Photos albums separately. Copy/paste that folder in your main Google Takeout directory (where you unzipped all the files) and merge the folders. This ensures that photos which were shared by others in your shared albums are actually copied to your album folders.
- Once this Google Takeout folder is ready, follow the instructions to run the script at the top level of this folder.
- This script assumes you are a Android/Pixel user as it does some HEIC to JPG conversions. It might need modifications if you want to keep HEIC files as HEIC.
- Go needs to be installed and be available on the path
go
- exiftool needs to be installed and be available on the path
exiftool
- This script has only been tested to work on Windows 10
- Clone or download this repository
- Open a Terminal/PowerShell at the root of the repo and run
go run main.go
- Enter the path to the folder where your Google takeout is, for example
E:\Google Photos
- The script will perform all the metadata updates and display the progress
At a top level, this script does the following:
- Renames all
.TS.mp4
files to just.mp4
- Renames any JSON metadata files which end in
.TS.mp4.json
or.TS.mp4.supp*.json
to end in just.mp4.json
to match the files updated in step 1 - Converts all HEIC files which have an associated HEIC.json file to JPG
- Renames the JSON metadata file associated with the HEIC file in step 3 to
JPG.json
for examplefilename.HEIC.json
would becomefilename.jpg.json
- Some JPG files are secretly WEBP files. Update the extension for these files to WEBP and update the associated JSON file to match for example
IMG_20240716_114215_778.jpg
becomesIMG_20240716_114215_778.webp
andIMG_20240716_114215_778.jpg.json
becomesIMG_20240716_114215_778.webp.json
- Updates the date/timestamp metadata of all photo and video files using the JSON metadata files using
exiftool
We do all of the above because:
- exiftool sometimes has trouble parsing files which have "double" extensions such as .TS.mp4, so we can just convert them to .mp4 without any issues. The
.TS.mp4
files are created by Top Shot or motion photos. - Google Photos converts HEIC files to JPG in their backend. However, when we download the files through Google Takeout, it keeps the .HEIC extension. exiftool does not like that, so we need to fix the extension to be JPG. Note that if you manually download Photo Albums from Google Photos (bypassing Googke Takeout) then any HEIC download are true HEIC, so we need to make sure we don't convert these files to JPG, which is why we check for a JSON metadata file first.
- Google provides us the metadata in the form of JSON files. We can fetch the metadata from these files and use exiftool to override the properties in the image/video files.
Google Takeout only stores your photos in your album folder and does not have photos shared by others in them. Even if you "Save" them in Google Photos, it only ends up in your "Photos from Year" folder and not your album folders.
The JSON metadata file can be in the following formats: filename.extension.json OR filename.extension.supplemental-metadata.json, filename.extension.supplemental-me.json, filename.extension.su*.json, and so on. It truncates the "supplemental" portion if the file name is > 47 chars. The script handles all of these cases.
View the tags in the json sidecar file:
exiftool -g1 -a -s 20231125_225835.jpg.json