Skip to main content
Participant
July 3, 2022
Question

remove Photos form collections

  • July 3, 2022
  • 1 reply
  • 478 views

Hello 

My solution for remove selected photo

local catalog = LrApplication.activeCatalog()

local photos = catalog:findPhotos {
    searchDesc = {
        criteria = "pick",
        operation = "==",
        value = -1
    }
}

catalog:withWriteAccessDo('with', function( )
    local collection = catalog:getCollections()
    collection:removePhotos( photos )
end, {timeout = 30})

But nothing happening when I execute code.

Please help me! What is wrong with this code?

This topic has been closed for replies.

1 reply

johnrellis
Legend
July 3, 2022

[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]

 

   local collection = catalog:getCollections()
   collection:removePhotos( photos )

 

The method catalog:getCollections() doesn't exist. There is catalog:getChildCollections(), but it returns an array of collections, not a single collection.

 

I'm guessing you're not using a debugger, since if you were, you'd see an error message like:

 

Without a debugger, LR sometimes displays Lua errors, sometimes not.

 

You should use either my Debugging Toolkit or the Zerobrane IDE.  Zerobrane IDE is a full-featured IDE for Lua, but my Debugging Toolkit better handles LR's specific tasking architecture.

 

Participant
July 4, 2022

Thank you for your advice! I will try to use your  Debugging Toolkit.

 

 

| The method catalog:getCollections() doesn't exist.

It is strange because I get this function from official docs

| Access the functions and properties from the object. Retrieve the objects for all the collections by

| calling LrCatalog.getCollections().

 

johnrellis
Legend
July 4, 2022

"It is strange because I get this function from official docs"

 

I just filed a bug report about that -- thanks for calling it out:

https://community.adobe.com/t5/lightroom-classic-bugs/minor-mistakes-in-sdk-documentation-referencing-lrcatalog-getcollections/idi-p/13048600