# Help needed with Plugin or Script



## Ash (Aug 19, 2017)

Hi

I've been using Lightroom since its early days and pride myself in being able to find ways of getting it to do as I want (even when it was not designed to do so! Lol). Even when the program itself has defeated me, I've managed to use Access to drill into the SQL file to extract the data I needed.

Now however I find myself in need of a script or plugin. Unfortunately though, with my advancing years and addled brain (thanks to 4 young children!), I find I'm no longer able to get my head around new programming languages the way I used to. I was therefore wondering if anyone could help me out in any way?

I need to be able to able to find image files quickly by just entering the 4 digit number found within most camera file numbering systems. I already use the great LR/Transporter plugin (which seems to work with any text file I've thrown at it,) however I need something that I can use within Lightroom  "on the fly". Ideally it would be an input requester that I can type a number into as I'm told it, and a matching (or several) image is added to a collection as I hit return. I could continue adding numbers, until I enter a specific, or empty string when finished.

I've not been able to find and efficient way of doing this apart from possibly via a script. If anyone has any suggestions, or can help me with even the bare bones of a lua script that I could build upon I'd be most grateful.  Alternatively please feel free to tell me how stupid I am as it can already be done by...... 

Thanks 

Ash


----------



## Gnits (Aug 19, 2017)

The following standard features might work.

1. Clear the quick collection by right clicking on it and select clear. Now set the Quick Collection as your Target collection.
2. Select All Photographs (or select a folder you might be interested in)
3. In Grid Mode.  Use \ to select filter.  Filter by Text ... Filename ...Contains  and enter the 4 digit number (1234)
4. Review the images shortlist. Select any of interest and hit the B key. This adds them to the Quick Collection.

Repeat.

At the end of the selection process you can decide what you want to do with the images collected inside your Quick Collection.

It is more difficult to write / describe than to actually do this in practice... and can be very quick.


----------



## Ash (Aug 19, 2017)

Hi Gnits
Thanks for taking the time to give it some thought and outline your suggestion. Unfortunately it's still rather too clumbersome and time consuming. I've tried several "standard" ways of doing it including a similar way of using and re-editing a smart collection with multiple filters.
In terms of speed and ease of use I really need something that for example would work over a phone conversation where I can input numbers as the other person reads them out then once finished being able to quickly see the images that they are talking about. Needless to say it's an international call on a mobile phone at peak rate!!! Lol 
Thanks anyway.


----------



## Rob_Cullen (Aug 20, 2017)

The nearest method I can imagine ( "on the fly" in LR without plugins) is the Text Filter-
Simply enter the four-digit numbers in the search field separated by a comma.

In my screen clip- with "all Photographs", my text of two numbers filters me to two photos. But you may have problems if the 4-number sequence appears in multiple photos.


----------



## Ash (Aug 20, 2017)

Hi I-See-Light
Thanks for getting in touch. To be honest I was unaware I could enter multi search matches separated by a comma! It makes it so much easier entering numbers all in one go. Although perhaps not as polished as a multi function script, it will certainly be an improvement, and linked with Gnits ideas, is something I can try when I require it.
Thank you both for the input.


----------



## PhilBurton (Aug 20, 2017)

Ash said:


> Hi
> 
> I've been using Lightroom since its early days and pride myself in being able to find ways of getting it to do as I want (even when it was not designed to do so! Lol). Even when the program itself has defeated me, I've managed to use Access to drill into the SQL file to extract the data I needed.


I'm a relatively new Lightroom user, since 4.4.  I'm curious as to how you can use Access to get into the sqlite file directly.  How to you configure Access to do that?  Do you have any standard queries that you've saved?  (and might be to share???)


> Now however I find myself in need of a script or plugin. Unfortunately though, with my advancing years and addled brain (thanks to 4 young children!),



Wait until they turn into teenagers.    

Phil


----------



## johnbeardy (Aug 20, 2017)

Phil, have you ever used ODBC to connect to databases? There are one or two ODBC drivers for SQLLite.

John


----------



## PhilBurton (Aug 21, 2017)

johnbeardy said:


> Phil, have you ever used ODBC to connect to databases? There are one or two ODBC drivers for SQLLite.
> 
> John


No.  Going from memory, Access can talk to an ODBC driver.  So if I have an ODBC driver for SQLLite, then I can access the Lightroom database?

Phil


----------



## johnbeardy (Aug 21, 2017)

That's the idea, Phil. ODBC it allows apps like Access or Excel to include tables linked from another SQL database such as the SQLLite catalogue. You can then build all the usual Access forms and reports, run read/write* queries, and mix Access tables with SQLLite ones.

That's in theory, and it does work - but it isn't necessarily practical. As I had used Access since 1992 it was my initial approach to automating tasks in LR . However,the catalogue database is not laid out for this sort of access. You can get some useful information, but the most interesting stuff is often stored as Lua code in text fields which are horrid to parse in an Access query. This led me to learn Lua and rely on the SDK.

Anyway, I think you already know those thoughts, so this was the driver I found most reliable SQLite ODBC Driver. After installing it, you need to go into the computer's ODBC manager and create an ODBC connection to the catalogue database. Then in Access you create a new linked table, pointing to this connection.

John

* NB writing to the catalogue is an easy way to corrupt the catalogue, sometimes silently (at first)


----------



## Gnits (Aug 21, 2017)

I agree completely with JohnBeardy. Also, unless you have access to really good documentation of the internal tables and fields it will be an exercise in frustration. 

In the early versions of Lr I was frustrated by the way my Catalog file seemed to be exploding in size and used Access to explore a copy of my catalog.  The exercise discouraged me from every attempting anything similar again.

I use the combination of Sqlite and Python for lots of small apps I need (which works on my Win, Mac and Raspberry Pi machines).  Python has become my default tool for any scripts I need to write. If you are familiar with Python this will allow you bypass the OBDC driver and use sql commands directly on the database.  I would not dream of writing any data to the database, as I would view that as a dead cert way for database corruption.


----------



## PhilBurton (Aug 21, 2017)

Gnits said:


> I agree completely with JohnBeardy. Also, unless you have access to really good documentation of the internal tables and fields it will be an exercise in frustration.
> 
> In the early versions of Lr I was frustrated by the way my Catalog file seemed to be exploding in size and used Access to explore a copy of my catalog.  The exercise discouraged me from every attempting anything similar again.
> 
> I use the combination of Sqlite and Python for lots of small apps I need (which works on my Win, Mac and Raspberry Pi machines).  Python has become my default tool for any scripts I need to write. If you are familiar with Python this will allow you bypass the OBDC driver and use sql commands directly on the database.  I would not dream of writing any data to the database, as I would view that as a dead cert way for database corruption.


Gnits and JohnBeardy,

I have no immediate need or plan to access the database directly.  I was asking this question out of curiosity.  Knowing that the LR database is not exactly an exemplar of good database design and implementation, I wouldn't DARE to write to the database directly.  However, I do know Access to a degree, but I'm not an Access expert in the way that i'm a PowerPoint or Word advanced user.

Gnits, I don't know Python, so I would go with ODBC.

Phil


----------



## Gnits (Aug 21, 2017)

I admire a lot of what is possible in Access and have used it for many mini projects.  I only recently got to know Python ( and glad I did). 

I took a 1 month subscription to  Lynda: Online Courses, Classes, Training, Tutorials , the training site.  There are a few Python courses. The target was to complete the courses in less than a month, so I only paid a single month subscription.  It was an incentive to myself to complete the course. Once the basics are grasped it is a lot quicker and easier than using Visual Basic in Access, but I miss the ease of the GUI design. Better in my view to get a structured course than trying to find an ad-hoc series of tutorials on the internet.

In your case | would be tempted to create a CSV file of the fields that you are interested in your catalog and use the  ListView or LrTransporter plug-ins to create a CSV file of the complete catalog (or specific folders).  You can then import to Access and use your Access skills. 

I use both of these plug-ins in conjunction with various scripting and programming languages to integrate Lr to Photoshop, InDesign, Powerpoint and MS Word.  I did a pre-dawn shoot of the Queen Mary coming into Dublin at dawn from a small fast rib (wet and windy) and took 611 raw images.  I was dropped off at the pier, wet and cold. I found the nearest cafe, ingested my raw files to a MacAir, selected the top 150 images, did a first edit to optimise exposure and crop. Within 15 mins I had sent a professional level pdf document (with footers and headers and page numbers, each image with a Title and Caption under it) emailed to my sponsor.   This is the value of automating workflow.  It is a pity Adobe do not make it easier to integrate Lr to other desktop applications.

If you need any assistance with Listview or LrTransporter (or Access) I will do my best to help.


----------



## Ash (Aug 21, 2017)

I see others have already answered your question, and I'd agree with what they say. Using Access is not the best way of going about things and keeping your sanity! 
I went down that route as I could find no other way of accessing data that i needed in the history section. As a result I can now query and find what I'm looking for and then write back data to the catalogue into other fields (yes that's the sort of crazy guy I am! Lol). Being very limited and controlled, I've yet to corrupt a catalogue (touch wood).
Beyond that I've only really played about and experimented a bit. However some success I had with linking a Lightroom database to another external one, does open up some interesting possibilities.


----------

