Copy link to clipboard
Copied
Hello,
I am able to add a photo by using catalog:addPhoto( path, stackWithPhoto, position )
I'd like to remove the photo once my operation is done. Or I'd like to completely remove the LrFolder from the Catalog.
Is there any way to do this? I didn't find a way in the SDK.
Any feedback would be greatly appreciated.
Thanks in advance!
Unfortunately, the SDK doesn't provide methods for removing photos or folders. I've always guessed that this was deliberate -- Adobe wanted to protect users from poorly written plugins.
As a klutzy workaround, one of my plugins takes this approach: When it's finished with an imported photo, it deletes the underlying file from disk and moves the LrPhoto into a special collection called "OK To Delete". Then the user can periodically delete that collection.
It's very unlikely at this point la
...Copy link to clipboard
Copied
Unfortunately, the SDK doesn't provide methods for removing photos or folders. I've always guessed that this was deliberate -- Adobe wanted to protect users from poorly written plugins.
As a klutzy workaround, one of my plugins takes this approach: When it's finished with an imported photo, it deletes the underlying file from disk and moves the LrPhoto into a special collection called "OK To Delete". Then the user can periodically delete that collection.
It's very unlikely at this point late in LR Classic's life that Adobe would ever add a delete method to LrPhoto.
[Use the reply button under the first post to ensure replies sort properly.]
Copy link to clipboard
Copied
@johnrellis thank you so much for your answer. IMO, SDK, at least, should allow removing photos which have been added by catalog:addPhoto but before this, there are lots of things to fix
Copy link to clipboard
Copied
@grcn you can delete files from the catelogue as well as from the directory folder.
1) For remove selected files from the actiev catalogue, use photo:addOrRemoveFromTargetCollection() function.
Below is the example to delete the files from the active catalogue.
local LrApplication = import "LrApplication"
local catalog = LrApplication.activeCatalog()
local photos = catalog:getTargetPhotos()
for p, photo in ipairs(photos ) do
photo:addOrRemoveFromTargetCollection()
end
2) Remove files from the targeted directory folder.
LrFileUtils.delete( path )Immediately deletes the file or directory at a given path. If the path refers to a directory, all of the contents are deleted. Use with care; in most cases, moveToTrash() is preferred.
First supported in version 1.3 of the Lightroom SDK.
1. path (string) The path.
(Boolean) True on success. On failure, can return a second parameter indicating the reason.
Here is the example how you can delete folder from the targeted path.
local LrFileUtils = import("LrFileUtils")
local exportPath = LrPathUtils.child(_PLUGIN.path, "Exported Photos")
local filePath = assert(exportPath .. "\\folderName\\")
LrFileUtils.delete(filePath)
I thing this will help a lot.
Thank you!
Copy link to clipboard
Copied
"For remove selected files from the active catalogue, use photo: addOrRemoveFromTargetCollection() function."
Unfortunately, that just adds or removes the photo from the target collection, not from the catalog itself.