• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

remove Photos form collections

Community Beginner ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

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?

TOPICS
macOS , SDK , Windows

Views

263

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

[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:

johnrellis_0-1656890049213.png

 

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2022 Jul 04, 2022

Copy link to clipboard

Copied

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().

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 04, 2022 Jul 04, 2022

Copy link to clipboard

Copied

LATEST

"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-referencin...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines