Copy link to clipboard
Copied
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:
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:
Any thoughts or advice appreciated.
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
...Copy link to clipboard
Copied
It may be possible. Scripts are possible eg. Get Filenames – Lightroom Solutions
(But I do not know scripting language to be able to help 😞 )
Copy link to clipboard
Copied
Thanks! Very helpful information.
Copy link to clipboard
Copied
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:
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.
Copy link to clipboard
Copied
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:
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.
Copy link to clipboard
Copied
Excellent, thanks for sharing your experience.
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now