5 Replies Latest reply on Dec 4, 2013 9:43 AM by areohbee

    programmatically force Lightroom to sync metadata

    victorvodka

      I want to automatically accomplish "Sync metadata" for a photo from within the Lightroom SDK (that is, programmatically).  Is this possible?

        • 1. Re: programmatically force Lightroom to sync metadata
          areohbee Level 5

          There is no SDK method to "sync metadata" per-se. So, I've done it in a variety of fashions, tailored to the situation...

           

          Some metadata you can sync by reading it using get{type]Metadata function(s) and write it via setRawMetadata, other metadata will require xmp tricks, or exiftool...

           

          PS - I don't think you can force sync'ing via UI (by stuffing keystrokes) because stuffed keystrokes can't see their way to a dialog box, and in this case they would need to. If you figure out how to aim a keystroke at a dialog box, I'd love to know about it.

           

          Rob

          • 2. Re: programmatically force Lightroom to sync metadata
            victorvodka Level 1

            just to be clear, i want to make sure the metadata makes it all the way to the sidecar files (raw images) and IPTC fields (in a jpeg).  it's not clear from the documentation where the "raw metadata" lives -- but i assume it lives in the Lightroom SQLite catalog, not in the images, and that syncing moved it to the sidecar and IPTC fields.  are you saying that in some cases setRawMetadata sets data all the way out to the sidecar/IPTC fields? 

             

            specifically i want to set keywords there, and  i know keywords do not move to sidecar/IPTC until i initiate a sync from the Lightroom menu (that is, non-programmatically)

            • 3. Re: programmatically force Lightroom to sync metadata
              johnrellis Most Valuable Participant

              i want to make sure the metadata makes it all the way to the sidecar files (raw images) and IPTC fields (in a jpeg).

              Ah, that's what you meant by "sync" -- it's such an overloaded word in Lightroom.

               

              You can try the undocumented photo:saveMetadata().   Search this forum for a little feedback from others who have tried it.

              • 4. Re: programmatically force Lightroom to sync metadata
                areohbee Level 5

                Saving metadata via the photo:saveMetadata method works in all modules, just note:

                * It's slow as molasses if you have to do a bunch.

                * it only initiates saving, i.e. it returns before it's saved, so if you want to assure it's saved before you act, you need to check it...

                 

                One might think since it's only initiating a save and returning before saved, it would be fast - but one would think wrong...

                 

                Download any of my plugins and look at Catalog.lua in Framework/Catalog folder and you'll see what I did - there are two methods:

                * saveMetadata (batch mode)

                * savePhotoMetadata ( single photo ).

                 

                Disclaimer: save-metadata function is not only undocumented, but it doesn't exist in Lr4 - so ya know..

                 

                ~R.

                • 5. Re: programmatically force Lightroom to sync metadata
                  areohbee Level 5

                  If all you want is to transfer metadata from catalog to xmp, then forget my first reply (I thought by "sync" you meant "transfer from one photo to another") and see my reply immediately previous to this one.