7

I just got thousands of photos out of Google takeout but I can't seem to import them elsewhere in the right chronological order. I've also found some tutorials using exiftool but I can't get the different timezones right? Any idea how to retrieve the time with the correct timezone? The timezone isn't in the JSON either.

EvaS
  • 73
  • 1
  • 1
  • 4

3 Answers3

6

There are now many scripts and tools available that can extract the metadata from JSON files and apply it to the photos and videos:

However, those scripts have limitations with regards to timezones, and to some pictures with a name that differs slightly from the name of the JSON file, e.g. PHOTO_NAME(1).jpg being confused with PHOTO_NAME.jpg(1).json. QuickTime- and PNG-specific tags aren't updated either.

If you're happy with those limitations,

  • Install ExifTool
  • Replace the directory to process and run the command exiftool -r -d %s -tagsfromfile "%d/%F.json" "-GPSAltitude<GeoDataAltitude" "-GPSLatitude<GeoDataLatitude" "-GPSLatitudeRef<GeoDataLatitude" "-GPSLongitude<GeoDataLongitude" "-GPSLongitudeRef<GeoDataLongitude" "-Keywords<Tags" "-Subject<Tags" "-Caption-Abstract<Description" "-ImageDescription<Description" "-DateTimeOriginal<PhotoTakenTimeTimestamp" -ext "*" -overwrite_original -progress --ext json <DirToProcess>

Otherwise, consider using a paid automated tool like https://metadatafixer.com/

Bathlamos
  • 312
  • 4
  • 10
  • 1
    This is awesome! The automated tool did the job perfectly since i couldn't figure out the timezones with Exiftool. Thanks! – EvaS Dec 09 '20 at 04:16
6

I did something like this for my QNAP NAS device. Uses simple text extraction and touches files with the oldest date found in the .json.

EDIT: Just adjust the touch spell so it matches your time format.

find . -name '*.json' | while read filename; do

    imgfile="$(echo "${filename}" | sed 's/\.json$//')" ;
    ts="$(cat "${filename}" | grep timestamp | awk -F'"' '{ print $4}' | sort | head -n 1)" ;
    ts="$(date -d "@${ts}" +"%Y-%m-%d %T")" ;

    if [ -f "${imgfile}" ];then
            echo Touching ${imgfile} ${ts}
            touch -t "${ts}" "${imgfile}"
    fi
done

As stated in the comments, on some Linux versions, touch expects [[CC]YY]MMDDhhmm[.ss] format, so replace the date line with:

ts="$(date -d "@${ts}" +"%Y%m%d%H%M.%S")" 
JrBenito
  • 973
  • 8
  • 30
szamil
  • 684
  • 5
  • 17
  • check your date format. I use PL locale, you might need fix the line with date. – szamil Apr 26 '21 at 20:51
  • 1
    On my Fedora 34 system, touch wants the [[CC]YY]MMDDhhmm[.ss] format, so I replaced the date line with: ts="$(date -d "@${ts}" +"%Y%m%d%H%M")" ; (I don't care about seconds). And then it worked great. Thanks a lot!! – Mikhail Ramendik Dec 02 '21 at 17:40
0

Here is a tested and very useful free tool for merging the metadata(.JSON) and photos. https://alamantus.github.io/GooglePhotosExportOrganizer/

This program will

  1. Extract and merge your Google Photos export from Google Takeout.

  2. Organize your photos into folders by year and month.

  3. Optionally rename your photos to a year-month-day hour:minute:second number.extension naming convention

  4. Fix all file created and modified dates as they are organized.

  5. Optionally copy all available metadata provided by Google Takeout in .json files back into the image/video files.

  6. Remind you to clean up after processing.