3 Replies Latest reply on May 12, 2013 7:40 AM by johnrellis

    How to find keyword object based on name

    dhmc05 Level 1

      I have a CSV file with file name and keywords.

      XXX_201300511_08765.CR2,Amsterdam

       

      These keywords already exist in Lightroom.

      Sample: Europe->Netherlands->Amsterdam

       

      I understand that with photo:addKeyword ( keyword object) I can add keywords to photos.

       

      How can I find the keyword object in Lightroom.

      For the example, how can I find the keyword object of Amsterdam.

        • 1. Re: How to find keyword object based on name
          johnrellis Most Valuable Participant

          If you want a table mapping the leaf names (e.g. "Amsterdam") to the corresponding LrKeyword objects, you'll have to write a recursive function that traverses the keyword hierarchy, building the table entries as you go.  You can get to the root of the hierarchy using catalog:getKeywords(), and you can get the children of any one LrKeyword object using keyword:getChildren().

          • 2. Re: How to find keyword object based on name
            dhmc05 Level 1

            Thank you John!, I was afraid that that would be the only solution.

             

            Imho the API of keywords should be extended with a function / method to retrieve all keywords objects based on the name description. I will make the suggestion apart.

            It is possible to find all photo object when supplying the name, like catalog:findPhotos and catalog:findPhotoByPath. Similar functions for keywords would be great.

             

            Are there code recipes for such a table implementations?

            • 3. Re: How to find keyword object based on name
              johnrellis Most Valuable Participant

              Are there code recipes for such a table implementations?

              I don't know of any published recipes or code examples for this.  The LR SDK community is pretty small, unfortunately.