How to merge image with his .json file (Google Photos takeout)

Started by Nick_0278, April 15, 2020, 03:17:17 PM

Previous topic - Next topic

lahratla

Quote from: Nick_0278 on April 16, 2020, 01:45:12 AM
Thanks StarGeek, you're right. I don't understand why Google is giving you all the JSON files again. This was also the reason why I thought they were separate.

Nevertheless, I really thank you for your helpfulness.

So, that this thread can still be useful for someone, is that the result:
(If you've got also a Googlephotos export you do not need to do anything!)

To search only in the given directory for images and merge them with their json files:

exiftool -ext jpg -tagsfromfile %d%f.%e.json -description '-gpslatitude<geodatalatitude' '-gpslatituderef<geodatalatitude' '-gpslongitude<geodatalongitude' '-gpslongituderef<geodatalongitude' '-gpsaltitude<geodataaltitude' '-createdate<creationdatetimestamp' '-datetimeoriginal<phototakentimetimestamp' '-modifydate<modificationtimetimestamp' -d %s xy/

-Where xy/ must be replaced with your directory

To search also in Subfolder(s) of the given directory for images, and them merge them:

exiftool -r -ext jpg -tagsfromfile %d%f.%e.json -description '-gpslatitude<geodatalatitude' '-gpslatituderef<geodatalatitude' '-gpslongitude<geodatalongitude' '-gpslongituderef<geodatalongitude' '-gpsaltitude<geodataaltitude' '-createdate<creationdatetimestamp' '-datetimeoriginal<phototakentimetimestamp' '-modifydate<modificationtimetimestamp' -d %s xy/

- Where xy/ must be replaced with your directory
- the -r stands for recursively

EDIT:
should I somehow mark the thread as solved?

- Nicko


I followed this method and copy-pasted the command line on CMD, but got "The system cannot find the file specified." Please help.

exiftool -r -ext jpg -tagsfromfile %d%f.%e.json -description '-gpslatitude<geodatalatitude' '-gpslatituderef<geodatalatitude' '-gpslongitude<geodatalongitude' '-gpslongituderef<geodatalongitude' '-gpsaltitude<geodataaltitude' '-createdate<creationdatetimestamp' '-datetimeoriginal<phototakentimetimestamp' '-modifydate<modificationtimetimestamp' -d %s xy/ E:\Pictures\GPhotos\GPhotos\Mine\Takeout\Google Photos\Photos from 2013\

StarGeek

Quote from: lahratla on June 22, 2022, 03:54:56 PM
I followed this method and copy-pasted the command line on CMD, but got "The system cannot find the file specified." Please help.

You have spaces in the file path.  Any parameter that has spaces in it must be quoted.  I dropped the slash from the end as it would escape the double quote and cause more problems.
"E:\Pictures\GPhotos\GPhotos\Mine\Takeout\Google Photos\Photos from 2013"
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

LemonFury

Hello.
I followed all instructions given by Phill Harvey in his first post in this conversation.
When I run the given command in the desired DIR, I get 2 errors about 2 json files that for some reason could not be opened and a message "1 directories scanned 349 image files updated 2 image files unchanged".
The main problem is that nothing changes (no date and gps info changes) in the initial JPG files in the folder but there are JPG_ORIGINAL files created for each JPEG.
If I use George.e 's method, I get no extra JPG_ORIGINAL files, i get the message "1 directories scanned 363 image files updated 2 image files unchanged" but in file properties dates are still the date that I downloaded them from Google Takeout.

Thank you for any tips provided.

u81

Hi,
I've read through all posts in this topic & made an attempt at running the script with the Win executable zip package. The output I get is as follows:

"C:\Downloads\exiftool-12.55>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 "C:\Downloads\Takeout\"
    1 directories scanned
    0 image files read

C:\Downloads\exiftool-12.55>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 "C:\Downloads\Takeout\Google Photos\"
    1 directories scanned
    0 image files read"

Takeout is the unzipped folder downloaded from Google Takeout & "Google Photos" is the immediate sub folder which contains the google photos albums in further subfolders.

Thanking you in anticipation of your advice.
R

Phil Harvey

Just try this to see what files ExifTool finds:

exiftool -filename -r "C:\Downloads\Takeout\Google Photos\"

Then try this:

dir "C:\Downloads\Takeout\Google Photos\"

and report back what you see.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

u81

Thank you very much for your swift response Phil. The outpout from the two commands above is as follows:

C:\Downloads\exiftool-12.55>exiftool -filename -r "C:\Downloads\Takeout\Google Photos\"
    1 directories scanned
    0 image files read

C:\Downloads\exiftool-12.55>dir "C:\Downloads\Takeout\Google Photos\"
 Volume in drive C is OS
 Volume Serial Number is 20EC-C40F

 Directory of C:\Downloads\Takeout\Google Photos

06/02/2023  15:32    <DIR>          .
06/02/2023  15:32    <DIR>          ..
06/02/2023  15:31    <DIR>          1 year ago
06/02/2023  15:31    <DIR>          1-2 North Main Street, Youghal
06/02/2023  15:32    <DIR>          10SouthAbbey
06/02/2023  15:31    <DIR>          12 years since___
06/02/2023  15:32    <DIR>          12FrancisStreet
06/02/2023  15:32    <DIR>          20210110CatherinePkWalk
06/02/2023  15:32    <DIR>          20211106-Kush_s 1st Birthday celebration
06/02/2023  15:31    <DIR>          20211107-Arleen_s 4th Birthday @ Cinnamon Garden
06/02/2023  15:31    <DIR>          20211218Saturday Night @ Sheikhs_
06/02/2023  15:31    <DIR>          20211224-Christmas Eve@ Pitalias_
06/02/2023  15:31    <DIR>          20211225- Christmas @ Gognas_
06/02/2023  15:32    <DIR>          20211225- Christmas @ Sheikhs_
06/02/2023  15:32    <DIR>          20220205-Dosa Outing _ Dinner with Rashi_Ashutosh
06/02/2023  15:31    <DIR>          20220211- Jains, Agarwals, Sheikhs _ Singhs
               0 File(s)              0 bytes
              16 Dir(s)  22,858,489,856 bytes free

Await your further advice.

Kind regards
R

Phil Harvey

That is a mystery.  I can't imagine how that can happen.  It seems as if the subdirectories exist but aren't visible to ExifTool for some reason.

Can any Windows person here suggest how this might happen?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

u81

While I was really hoping for the solution. You finding the issue a mystery makes me feel a little less dumb...

I appreciate your response and hope someone else will be able to advise further soon.

Thank you very much.
R

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Ah, got it.  The trailing backslash means that the last double quote is escaped.  Which means that exiftool is receiving
C:\Downloads\Takeout\Google Photos"
as the directory name.

Either remove the slash
"C:\Downloads\Takeout\Google Photos"

or double it
C:\Downloads\Takeout\Google Photos\\"

Or switch to forward slashes, either all or just the last one
C:\Downloads\Takeout\Google Photos/"

I remember this has come up before, but can't find the thread atm.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

@StarGeek:  Excellent sleuthing!!!

I find it surprising and somewhat disconcerting that the command-line arguments are parsed differently for different commands ("exiftool" vs. "dir). :(

- Phil

Edit: Hmmm.  But now I don't understand why ExifTool would report that 1 directory was scanned.  :-\
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

I also forget that I have script that automatically avoids the problem. One program I regularly use always passes the directory to the clipboard with the trailing slash.  I have an autohotkey script (or maybe it's autoit) which takes care of it.

Finally found the previous case of the trailing slash.  It was only 7½ years ago :)
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Quote from: StarGeek on February 09, 2023, 04:14:09 PMIt was only 7½ years ago :)

There must have been more recent cases too because I had a recollection of this once you mentioned it and my memory isn't that good. :P

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

u81

Thank you very much Phil & StarGeek for your advice.

Appending a "\" did the trick. The result this time was as follows:

 15 directories scanned
 1003 image files updated
   42 image files unchanged

I shall now embark on the large scale editing. I shall now try re-uploading these on Google Photos to see if the edits are picked up in that app as desired.

Many thanks once again.

Kind regards
R

u81

Hi Phil & StarGeek,

The changed command is now working. However, I've run into an issue having edited & uploaded the first 30GB (off a 1.7TB photo/ video collection exported from two separate Google Photos collections) to a single new Google Photos a/c.

I am unable to download the whole directory backup due to lack of SSD space. So, I'm doing this batches of 4GB.

Many images are now showing in the new Google Photos A/c with the correct date but getting sorted with a wrong date. For example - a file with the correct date of 20130324 file named (20130324_171440-MIX) is getting picked up with a date of 17/06/2013. I manually edited the date on Google photos so it is now showing in the correct date album on that application. I then downloaded a copy & it is still reading a creation date of 17/06/2013. This is a pattern observed in many cases.

It is highly likely that the images were manually sorted into those google photos albums (actually in Google Picasa even before Google photos was launched) and while they showed correctly in Google Photos in one account, the edited dates did not get saved to the actual file, which is what we needed this script to extract from the json tags.

The other possibility is that these were images received from WhatsApp or older cameras without the correct creation date.

So, I would be obliged for any ideas on how this problem can be surmounted. As In, if there is a date exported album from Google photos (in a date folder), is it possible to ensure that the file's time taken tag is matched with it?

Manually checking, downloading, fixing, reuploading the images is an extremely daunting exercise that I would like to avoid but would still do if the results are permanent.

Is there less a cumbersome way whereby I might be able to compare the file name & the time taken tag in bulk and edit them?

For images that don't contain the correct taken date in the file name, I guess it will have to a manual exercise, on a one by one basis, or have you any ideas how I might be able to do that in bulk as well.

All advice welcome.

Thanking you
R