using pyexiftool wrapper with exiftool cli on macos, read meta ok, but not write

Started by zabalex, October 19, 2021, 10:15:07 PM

Previous topic - Next topic

zabalex

Hello Phil, thanks for this great tool,

I have this question, I can't seem to find an answer in this forum, hopefully this is not too complicated.

I'm using python 3.x on my mac. I am trying to find a way to read XMP:

                file_name = [src_dir + infile]
                with exiftool.ExifTool() as et:
                    metadata = et.get_metadata_batch(file_name)
                    rating = metadata[0]['XMP:Rating'] #  <-- this gets me the rating variable directly! [Excellent]


Now, I need to set this rating back, incrementing or decrementing the value depending on some logic in my program, so if it is 3, I need to output 3+1 = 4.

The only way I could figure this out is with exiftool cli calling a subprocess. Inside the process I call this:
exiftool -xmp:Rating=3 outputfilename # <-- and it works, but the obvious question is, can I do it all from within a python wrapper, or any other piece of code that you could recommend?

Thanks to everyone who made it all possible ;)