For a project where I am merging a massive Lightroom photo catalogue with our Assetbank DAM system using Exiftool and Google sheets I need to assign Lightroom keywords to tags.
In my Google sheet I match each individual keyword with a an exhaustive keyword list where each entry has the respective tag assignment next to it.
This works great to build the final exiftool command to write all keywords as tags. As long as there is not multiple keywords that belong to the same attribute (the attribute is the "category", for example the country or city).
You can see what it looks like in Google sheets in the attached screenshot.
I managed to replace the assignment ('=') to appending the new keyword with the "copy from tag". For example exiftool -XMP:Subject-= '-XMP:Subject<$XMP:Subject 13th Dalai Lama' .
But for this to work there has to be already an existing tag XMP:subject.
Can you please tell me the correct command to append only if the tag exists and otherwise use the assignment? I am working on Mac OS, so it would be great if you could use the syntax (quotes etc.) for the bash shell. Thanks a lot for your help in advance.
warm regards,
Harald
Greetings Harald, the += can say "append", and there is -wm w to say "WriteMode: Only write existing tags", so Im thinking maybe????
exiftool -wm w '-XMP:Subject+= 13th Dalai Lama' 'FolderPath'
But just remove -wm w if wanting to create $XMP:Subject if not existing, because += really says "append or create".
(There is an extra space before 13th, so just remove if its not really wanted)
If wanting to make sure that ' 13th Dalai Lama' is not already in there????
exiftool -if '$XMP:Subject !~ / 13th Dalai Lama/' '-XMP:Subject+= 13th Dalai Lama' 'FolderPath'
So it only adds/creates if not already there, but still must remove both spaces if not wanted before 13th.
Quote from: Harald on March 22, 2021, 10:52:34 AM
I managed to replace the assignment ('=') to appending the new keyword with the "copy from tag". For example exiftool -XMP:Subject-= '-XMP:Subject<$XMP:Subject 13th Dalai Lama' .
Clarification, are you adding a new keyword, or adding more text to an existing keyword? For example (checks wikipedia), if you already have the keyword
Thubten Gyatso, are you attempting to make the result two keywords:
Thubten Gyatso13th Dalai Lamaor a single keywords
Thubten Gyatso 13th Dalai LamaYour example,
'-XMP:Subject<$XMP:Subject 13th Dalai Lama', would create the latter situation. Luuk2005's examples are of the former situation.
XMP:Subject is a list type tag, so you might want to read up on FAQ #17 (https://exiftool.org/faq.html#Q17) for more details.
Thanks a lot to Star Geek and Luuk2005!
@StarGeek: Thanks for clarifying. Indeed I want to create separate keywords, so Luuk2005's response is perfect.
@Luuk2005: yes, just "+=" is what I want. If not there, the tag should be created and get the value of that gSheet cell.
And I was not aware of the two spaces, well spotted, thanks.
There should be no values in these fields before I run the script, so checking for existing is not necessary. But still great to know about that option, thanks.
And I am aware of the += working only for keyword lists, thanks StarGeek for pointing this out.
In my tests your command works flawlessly.
I deeply appreciate the support you guys give in this forum and try to give back to society to return your favours. Please keep it up.
warm regards, Harald