ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: chono on November 07, 2021, 01:41:22 PM

Title: Google Photos - Error opening file '-edited' and '(1)' JSON
Post by: chono on November 07, 2021, 01:41:22 PM
I'm betting that this is a common issue with folks using ExifTool with a Google Photos Takeout set..
So I'm hoping that someone clever has figured out a nice pattern match thingy with the 'tagsfromfile' option that matches:

somefile.jpg --> somefile.jpg.json
somefile-edited.jpg --> somefile.jpg.json
somefile(1).jpg --> somefile.jpg.json
somefile(2).jpg --> somefile.jpg.json


The option I currently use stictly looks for a filename.json.. Where what I need is filerootname.json where the rootname ignores suffixes like '-edited' and '(/d+)'

-tagsfromfile "%d/%F.json"


And for completeness - these are the warnings:

Warning: Error opening file - path/to/somefile-edited.jpg.json
Nothing changed in path/to/somefile-edited.jpg
Warning: Error opening file - path/to/someotherfile(1).jpeg.json
Nothing changed in path/to/someotherfile(1).jpeg


Does anyone have a clever workaround?
Title: Re: Google Photos - Error opening file '-edited' and '(1)' JSON
Post by: chono on November 07, 2021, 03:21:44 PM
Looking closer -

It looks like when there are more than one image with the same name - photos renames them like this:

Image1.jpg
Image1(1).jpg


and then on takeout it makes this mapping:

Image1.jpg --> Image1.jpg.json
Image1(1).jpg --> Image1.jpg(1).json


which is a different issue than a missing json file for the -edited ones.
Title: Re: Google Photos - Error opening file '-edited' and '(1)' JSON
Post by: StarGeek on November 07, 2021, 03:34:20 PM
I forgot to mention in the other thread that unless you made changes on the Google Photos website, you do not need to rewrite the metadata.  Google photos does not remove metadata from the files.

Your best thing to do in the case of (1), (2), etc files is to rename the json files. For each file with a copy number, there should be a matching json file with the copy number in the wrong place.  See this post (https://exiftool.org/forum/index.php?topic=12882.msg69636#msg69636).

I hadn't see "edited" files before, but I'm guessing that there should be a matching json file with the "edited" part out of place.  Assuming the position is the same, then the command to rename the json files would be
exiftool -ext json -r -if '$Filename=~/(-edited).json$$/i'  '-Filename<${Filename;s/(\.[^.]+)(-edited).json$/$2$1.json/}' /path/to/Takeout/

Then you can run the regular commands.
Title: Re: Google Photos - Error opening file '-edited' and '(1)' JSON
Post by: chono on November 08, 2021, 12:40:07 PM
Thanks.
I ended up making a little helper script to preprocess and handle the oddball cases.