Google Photos - Error opening file '-edited' and '(1)' JSON

Started by chono, November 07, 2021, 01:41:22 PM

Previous topic - Next topic

chono

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?

chono

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.

StarGeek

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.

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.
* 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).

chono

Thanks.
I ended up making a little helper script to preprocess and handle the oddball cases.