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

Is it (still) possible to write "scripts" for LrC?

Explorer ,
Dec 11, 2022 Dec 11, 2022

I have 3000+ bird photos that I "tagged" for searching prior to using LrC. Since I was not using any sophisticated photo processing tool like LrC, I had no way of easily adding metadata like keywords. I devised a file naming scheme that served my searching needs; it included a species name (a standard 4-letter abbreviation) and some aspects of the photo, e.g., gender, plumage, etc. 

 

Now that I've moved to LrC, I am using keywords for the same searching needs. However, I still have those 3000+ photos imported into LrC and they have no keywords at all. As former professional programming I thought it would be nice to be able to write a script or macro or program that would:

  • iterate through a folder containing all those photos
  • get the file name of the photo
  • parse the file name to determine the species and all aspects for the photo
  • open the photo (or whatever is needed to support the next step)
  • add appropriate keywords to the photo
  • close the file (if needed)

 

I've discovered that Adobe officially supports writing "plugins" that might support doing what I propose. However, I don't think I need a plugin as this would in theory be a one time thing. There is some evidence that you can write "scripts" that don't have to have all of the complexity of a plugin (see https://helpx.adobe.com/lightroom-classic/kb/extract-previews-for-lost-images-lightroom.html). However, newer versions of LrC might not support this. 

 

I'm looking into the documentation, but thought I'd ask the community if:

  • the notion of a script rather than plugin is still supported
  • the Lua programming language and its reach into LrC would support what I want to do
  • there are additional resources that would help
  • the work involved would be reasonable; I can probably do all the species keywording in less than a day; the rest would take several days

 

Any thoughts or advice appreciated.

TOPICS
SDK
5.3K
Translate
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

Explorer , Dec 14, 2022 Dec 14, 2022

I answered my own question. It is possible, because I did it!

 

I absolutely built on the work of others, e.g., the material mentioned by those who replied to my original post, plus additional material found with internet searches. I'd have to say the most important asset was a working script that I used as a starting point. It took me 3 calander days to achieve my goal, maybe 20 hours of actual work (searching, thinking, programming, testing). While that sounds like a lot of time, I believe it to

...
Translate
Community Expert ,
Dec 11, 2022 Dec 11, 2022

It may be possible. Scripts are possible eg. Get Filenames – Lightroom Solutions 

(But I do not know scripting language to be able to help 😞  )

 

Regards. My System: Windows-11, Lightroom-Classic 14.5.1, Photoshop 26.10, ACR 17.5, Lightroom 8.5, Lr-iOS 10.4.0, Bridge 15.1.1 .
Translate
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
Explorer ,
Dec 11, 2022 Dec 11, 2022

Thanks! Very helpful information.

Translate
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 ,
Dec 11, 2022 Dec 11, 2022

It is indeed possible to write stand-alone scripts rather than full plugins.  A script is just a .lua file placed in the Scripts subfolder of the Lightroom settings folder. It is otherwise identical to the .lua file that would implement a menu command of a plugin.

 

You can download the Lightroom Classic SDK from adobe.io.  I can't give you a direct link because the web site doesn't allow it (it's one of the worst corporate web sites I've ever used).  The SDK includes a fairly thorough and well-written Lightroom Classic SDK Programmers Guide.

 

But it's a pretty steep learning curve: a couple hours to get passingly comfortable with Lua, a couple hours reading the SDK, discovering there are very few open-source examples out there, investing in a debugging solution after learning that print statements won't cut it, etc:

https://community.adobe.com/t5/lightroom-classic-discussions/sample-code-for-a-publish-service/m-p/7... 

 

I think you'd be lucky to get a working script in less than 8 hours, perhaps longer.

 

An alternative approach is completely manual: Use the Library Filter bar to search for filenames containing a specific string, and then assign the appropriate keyword to all the matching files.  Tedious, but perhaps significantly less than 8 hours.  

 

If the simple string match of the Library Filter bar isn't sufficient, you could use the pattern matching of filenames available in the Any Filter plugin.

 

 

 

 

Translate
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
Explorer ,
Dec 14, 2022 Dec 14, 2022

I answered my own question. It is possible, because I did it!

 

I absolutely built on the work of others, e.g., the material mentioned by those who replied to my original post, plus additional material found with internet searches. I'd have to say the most important asset was a working script that I used as a starting point. It took me 3 calander days to achieve my goal, maybe 20 hours of actual work (searching, thinking, programming, testing). While that sounds like a lot of time, I believe it took less time to accomplish adding keywords automatically rather than manually, so I'm quite happy. Plus, I learned something new.

 

I admit that I took a lazy approach. For simplicity, I decided to create a script rather than a plugin. I downloaded the SDK, but since it focused on plugins, I did not install anything or even closely examine the examples. I did not use any IDE or even a Lua knowledgeable editor. I did not try any of the debuggers mentioned in various places. I used the API documentation from the SDK download. I used TextEdit for programming. I used the moral equivalent of print statements for debugging. I took a very iterative approach, starting with the working script mentioned above (it simply gets photo file names) and slowly added various non-destructive actions before actually making any changes to the catalog. At some point I discovered that a keyword has to exist before you can add it to a photo, so I decided to create two scripts, one to create all the needed keywords and a second to add existing keywords to photos. This was not the most efficient way, but it did allow me to test creating keywords independently and then backing up the catalog before addiing keywords to photos.

 

I admit it was a bit of a challenge; for example:

  • I've not used Lua before, so I had to do a lot of searching to find out how to do  even simple things like for loops
  • Lua's use of data types like tables and functions was a bit confusing, coming from my world dominated by Java, C++, and Python (if you want a really good time, look at sorting a table of tables)
  • I've never used the LrC API before; the API documentation is decent, but could use some code examples; further, I could not find anything like a user's guide on how to create a complete script (that said, I'm pretty sure I could never create a complete Java program just looking at the Java API)  

 

The net is that I was able to automate adding a few hundred keywords to LrC, with the keyword name based on content of the file names of almost 3800 photos, and then automate adding keywords (some of which already existed) to the 3800 photos based on the photo file name. I made no attempt to achieve efficiency, and the two steps together took around 10 minutes on my M1-based MacBook Pro. 

 

At this time I am not attaching the two Lua files to the post. The code is a bit ugly, e.g., not necessarily properly formatted, full of "debug statements" (many of which are simply commented out), contains hastily named variables. That said, if anyone would like to see the code I will post the files in a reply. 

 

Translate
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 ,
Dec 14, 2022 Dec 14, 2022

Excellent, thanks for sharing your experience.

Translate
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
New Here ,
Jan 09, 2025 Jan 09, 2025
LATEST

A bit late to the party but exiftool allows you to change a files metadata and just reimport. Easy to use if you know bash or similar. I used it to change file creation dates and location 

Translate
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