deleting hierarchical keywords using a metadata template?

Started by Joe Austin, January 30, 2015, 02:42:34 PM

Previous topic - Next topic

Joe Austin

Is this possible?   How would it be done?   I understand from the docs how to add keywords via template, but I don't see a way to remove them.


Very tricky, of possible at all.
You could try using the hierarchical keywords variable as input, a replace function to replace the unwanted keyword with an empty string. May work. Did not try.

Why not just select all files in question, delete the keyword in the KW panel, and save?
-- Mario
IMatch Developer
Forum Administrator  -  Contact & Support - Follow me on 𝕏 - Like on Facebook


If you want to delete all keywords from a number of files, then what I would do is select those files, go to the keyword panel, and use the "delete all keywords" drop-down option in the panel toolbar.  Simple enough, although you'd also need to trigger writeback and refresh @Keywords, but that's the case for a metadata template as well.

Joe Austin

My desire to delete keywords is an agency-specific workflow thing.   I use some common keywords that an agency does not want in the images I submit to them so I wanted to create a favorite that could , with one click, remove 3-4 specific keywords from a selection of images, and perform a couple other agency related metadata tasks.


Is it that cumbersome to delete them in the keywords panel?  I suppose you could script this if you really want to automate it, although it sounds to me like these particular keywords would be better as categories.


I gave this a little test.

I used the following variable


(Replace banana; with 'nothing')

The variable returns, for example:


and after applying the template we have


Works great. You can add multiple replace commands so you can replace multiple keywords.
ye mighty variables!
-- Mario
IMatch Developer
Forum Administrator  -  Contact & Support - Follow me on 𝕏 - Like on Facebook

Joe Austin

I had considered that method, but did not think about using the ';' to define the end of the keyword and was afraid it would be difficult to predict the results if looking for strings throughout the keywords.

I tried your method using this syntax:


on this keyword string:

   mammal; animal; fauna; Wildlife; mammals; Mammals; nature; one|two|mammals; animals; alpha; alpha|wildlife|beta

the result was:

   mammal; animal; fauna; one|two|alpha; alpha|wildlife|beta

The 'wildlife' in the 'alpha|wildlife|beta' word was not removed as expected (does not end with ';'),  but the 'mammals' at the end of 'one|two|mammals' was removed, along with its ';', resulting in 'alpha' being appended to the end of that hierarchical keyword.

I tried the same syntax on the XMP/dc/subject tag, to alter the non-hierarchical keywords.   The effect was correct, but it was reset back to the value of the Lightroom\hierarchicalSubject keywords field as soon as Imatch updated the image.

So I changed the syntax to this:


removing the word, but not its trailing ';'.    The result was:

   mammal; animal; fauna; alpha|wildlife|beta; one|two|; alpha

which I believe is the result I want to achieve.

Thanks for the tip.