I have a keywords list that looks similar to this:
Keywords : Merlin ID:139777188, 20190227, REMOTE, "Merlin Crop: 0 0 2489 1376"
I need to add a new "Merlin Crop: ? ? ? ?" keyword instead of existing one(if present). The hard part is to do this in one exiftool command run, as in our architecture for every exiftool call a microservice is invoked through HTTP with image attached, meaning we could save a lot of time if we do it in one call instead of two.
What I tried so far:
exiftool '-keywords<${keywords@;$_="Merlin Crop 1 2 3 4" if /.?Merlin Crop.*/}' image.jpg - works only if there's a Merlin Crop keyword already in the list.
exiftool '-keywords<${keywords@;$_=undef if /.?Merlin Crop.*/}' -keywords+='"Merlin Crop 1 2 3 4"' image.jpg - looks like only -keywords+= gets executed and old Merlin Crop is still in the list.
Could someone please help me figure out the proper way to combine these two?
You were very close, but the += is not necessary since you were already copying the other keywords. Also, you need the -sep option to break the keywords apart again after they are interpolated in the string. Try this:
exiftool '-keywords<${keywords@;$_=undef if /.?Merlin Crop.*/}' -keywords='"Merlin Crop 1 2 3 4"' -sep // image.jpg
- Phil
Perfect! Works like a charm. :)
Thanks for your help, Phil, much appreciated.
PS: exiftool is pretty cool :)
Quote from: Elazul on January 31, 2020, 07:58:13 AM
PS: exiftool is pretty cool :)
You must be a true geek. ;)