Skip to main content
Inspiring
January 29, 2024
Answered

SDK rename and move to parent folder

  • January 29, 2024
  • 1 reply
  • 378 views

I'm working on my first plugin and so far i'm quite happy.
As an analog photographer, i digitise my film with an digital camera adding up with something like DSC56788.raw.

Then I convert with NLP, that creates a subfolder positives and DSC56788-positive.tif

Now I need rename them always by hand, and if this can go using my myplugin my workflow will be 10 times faster.

So select all files rename to a 'prefixname'-01.tif and the numbers should be increasing, after that my plugin runs exiftool based on those new filenames, and updates the metadata.

So some pointers to help me out, if possible ?

I know how to loop and increase numbers, but it's the catalog commands i'm stuck with.

thx

Patrick

This topic has been closed for replies.
Correct answer johnrellis

If you use LrFileUtils to rename/move a file that's been imported into the catalog, LR will now think that the photo is missing. There's no way for the plugin to reconnect that missing file with its new location.

 

The plugin could invoke catalog:addPhoto() to import the files in their new location, but the catalog would still contain the now-missing files imported at their old location, and there would be no way for the plugin to delete them from the catalog. 

 

One of my plugins moves images that should be removed from the catalog into a special collection and tells the user those images can now be removed from the catalog.

1 reply

johnrellis
Legend
January 29, 2024

The SDK's LrFileUtils provides methods for renaming and moving files in the operating system but not within the catalog, unfortunately.

 

The best you can is to batch rename manually using the Library > Rename Photos command, with a renaming template that provides the prefix and specifies increasing sequence numbers. If the tokens in renaming templates don't do precisely what you want, your plugin could store the desired filenames in an unused metadata field, e.g. Headline, and then you could manually rename the batch with Rename Photos, using a template that used Headline.

Inspiring
January 29, 2024

So if i use the LrFileUtils ro rename and move the files, is there a way to do a scan for new files?

or the addPhotos ?

thx

johnrellis
johnrellisCorrect answer
Legend
January 29, 2024

If you use LrFileUtils to rename/move a file that's been imported into the catalog, LR will now think that the photo is missing. There's no way for the plugin to reconnect that missing file with its new location.

 

The plugin could invoke catalog:addPhoto() to import the files in their new location, but the catalog would still contain the now-missing files imported at their old location, and there would be no way for the plugin to delete them from the catalog. 

 

One of my plugins moves images that should be removed from the catalog into a special collection and tells the user those images can now be removed from the catalog.