Skip to main content
Participant
November 20, 2015
Answered

Error adding keywords that already exist

  • November 20, 2015
  • 2 replies
  • 650 views

hello.

I'm trying to add a single keyword to multiple photos on export.  It works on the first image, but fails on all images.  Is there a way to generate the keyword by testing the catalog to see if the keyword already exists, and if not, then add it?

Is there a way to do this w/out first traversing the entire catalog's keyword hierarchy?

Thanks

This topic has been closed for replies.
Correct answer johnrellis

Also, if you know the parent keyword of the keyword you're looking for, you can use the "returnExisting" parameter of catalog:createKeyword() to create the keyword (if it doesn't exist) or return it (if it does exist).

2 replies

J LipAuthor
Participant
November 24, 2015

This is exactly what I needed, thanks for the pointer.

J LipAuthor
Participant
November 20, 2015

meant to say " but fails on all OTHER images"

johnrellis
Legend
November 20, 2015

The only way to determine if a keyword exists is to examine the appropriate part of the hierarchy (or the entire hierarchy, if you don't know where the keyword might be).  But you only need to do that once per export.

You could store the keyword in the LrExportSession object under your own key.  E.g.

if session.myKeyword == nil then

    session.myKeyword = look up keyword, creating it if necessary

    end

That way, you don't have to look up the keyword for each photo.

johnrellis
johnrellisCorrect answer
Legend
November 21, 2015

Also, if you know the parent keyword of the keyword you're looking for, you can use the "returnExisting" parameter of catalog:createKeyword() to create the keyword (if it doesn't exist) or return it (if it does exist).