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

Using LR Classic SDK to remove files from catalog

Community Beginner ,
Jun 26, 2022 Jun 26, 2022

Copy link to clipboard

Copied

Hi,

 

When importing media from mobile devices, I ended up with a lot of files under the wrong folders. I'm creating a Library plugin to relocate them based on capture time. My strategy is to call LrCatalog.addPhoto() on the file path and that has worked nicely in my testing.

 

Now I have 2 copies of the same file in LR, the original copy in the wrong directory and the new copy. Is there a way to achieve something like LrCatalog.removePhoto() to get rid of the old copy? I know I can remove the file with LrFileUtils, but how to update the catalog?

 

Thanks

Yi

TOPICS
SDK

Views

168

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

correct answers 1 Correct answer

LEGEND , Jun 28, 2022 Jun 28, 2022

The SDK won't let you remove photos from the catalog proper.  In your case, a script or plugin can use LrFileUtils.delete (photo.path) to remove a photo from disk.  Then when you're done, manually invoke Library > Find All Missing Photos, select the thumbnails marked missing, and remove them from the catalog.  


Alternatively, when your script deletes a photo from disk, it can also add it to a collection "To Be Deleted".  You can then manually remove the photos in that collection from the catalog.

Votes

Translate

Translate
LEGEND ,
Jun 28, 2022 Jun 28, 2022

Copy link to clipboard

Copied

The SDK won't let you remove photos from the catalog proper.  In your case, a script or plugin can use LrFileUtils.delete (photo.path) to remove a photo from disk.  Then when you're done, manually invoke Library > Find All Missing Photos, select the thumbnails marked missing, and remove them from the catalog.  


Alternatively, when your script deletes a photo from disk, it can also add it to a collection "To Be Deleted".  You can then manually remove the photos in that collection from the catalog.

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 ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Thanks! The first method worked, although it took quite a while to run since there were a lot of photos.

 

I don't fully understand the second approach though. If it worked, it'd be a great optimization. I'm able to move the photos to a "To Be Deleted" collection. But removing the photos from that collection afterwards affected only the collection itself. It didn't help remove them from their folders, which is what I tried to achieve. Did I miss anything? 

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 ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

"But removing the photos from that collection afterwards affected only the collection itself. It didn't help remove them from their folders, which is what I tried to achieve. Did I miss anything?"

 

You'll need to use the menu command Photo > Remove Photos From Catalog (see the menu item for the keyboard shortcut).  When in a collection, Delete / Backspace just removes the photo from the collection.

 

 

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 ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Worked beautifully! Thanks!

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 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

LATEST

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