2 Replies Latest reply on Oct 18, 2010 4:06 PM by Lichtzeichenanlage

    catalog:batchGetFormattedMetadata problem?


      I'm new to the Lightroom 3.0 SDK, but found catalog:findPhotos and photo:getFormattedMetadata to work satisfactorily.


      But, when I tried "catalog:batchGetFormattedMetadata" it returned an empty table.  Can anyone point out what I may be doing wrong is this little code snippet?

      The returned resultTable has 0 length, though there are photos in the catalog: "catalog:getAllPhotos()"


      import "LrTasks".startAsyncTask( function()
           local LrLogger = import 'LrLogger'
           local myLogger = LrLogger( 'libraryLogger' ) -- the log file name
           myLogger:enable( "logfile" )

           local catalog = import "LrApplication".activeCatalog()

           local resultTable = catalog:batchGetFormattedMetadata ( catalog:getAllPhotos(), nil )
           myLogger:trace( #resultTable )

      end )


      Windows 7, 64-bit, Lightroom 3

        • 1. Re: catalog:batchGetFormattedMetadata problem?
          john beardsworth Adobe Community Professional & MVP

          It's a funny kind of table that you need to parse using pairs, not ipairs.





          local cat =  import "LrApplication".activeCatalog()

          local dialogs = import "LrDialogs"


          import 'LrTasks'.startAsyncTask(function()
              local keys = {'title', 'caption', 'headline'}
              local photos = cat.targetPhotos
              --local metaData = cat:batchGetFormattedMetadata(photos,keys)
              local metaData = cat:batchGetFormattedMetadata(photos)
              local rawData = cat:batchGetRawMetadata(photos, {'uuid'})
              for photo, md in pairs(metaData) do
                  local p = (tostring(photo))
                  local buff = p ..  "\n"
                      for k, m in pairs(md) do
                      buff = buff ..  k .. ": ".. m  .. "\n"
                  dialogs.message("Calling the key directly", md['caption'] )

          • 2. Re: catalog:batchGetFormattedMetadata problem?
            Lichtzeichenanlage Level 1



            you can process the table with ipairs, but you have to know, that photo is the key to the table:


            function LZA.fred(photos)
               local batchedMetadata = catalog:batchGetFormattedMetadata(photos, {"isVirtualCopy", "countVirtualCopies", "virtualCopies",})
               for index, photo in ipairs(photos) do
                  local isVirtualCopy = batchedMetadata[photo].isVirtualCopy


            rgds - wilko