How can I find which Lightroom catalog contains a specific photo?

Asked 11/16/2016

9 views

2 answers

0

I have a photo file on disk and know its filename and full path. The file has stayed in the same location on a Windows system, but over the years I ended up with many Lightroom catalogs. I’m trying to identify which catalog contains this image so I can reopen the edit and re-export it. Is there a way to search across multiple .lrcat files for a specific image path or filename?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

9y ago

2 Answers

4

This is perhaps not what you want to hear, but you should consider either using one (or very few) catalogs, or organizing the physical files so they are contextually associated with the catalogs. I guess it depends on scale, but catalogs can support 100,000 images easily (I have yet to hear of someone who hit a limit, my own is about 80,000). A key purpose of a catalog is to let you find things - using a lot of catalogs somewhat defeats the purpose.

Now that said, you did not ask "talk me out of doing it" so here's a pointer in a possible direction: the catalogs are just sqlite databases. If you are a bit tech savy, you can use any of numerous tools to query the databases (e.g. in a script to run against each one). To check if a catalog contains a specific file (name in the last line below):

select *
from 
(
  select rf.absolutePath || lfo.pathFromRoot || lf.baseName || '.' ||  lf.extension as imagePath 
  from Adobe_images ai
  inner join AgLibraryFile lf on lf.id_local = ai.rootFile
  inner join AgLibraryFolder lfo on lfo.id_local = lf.folder
  inner join AgLibraryRootFolder rf on rf.id_local = lfo.rootFolder
  where ai.masterimage is null 
) x
where x.imagePath = 'C:/somefolderpath/LR-20080704_4881.NEF'

The part in the middle returns a list of all files with their on-disk path, the outer part looks for a particular one among them. Run just the middle to list all files. Variations (such as looking only at lf.baseName) can be used if your file names are unique and you want to ignore the paths.

Sticking this inside of powershell or some other scripting language would depend on your preferred tools, skills and how frequently you want to do it. To do it manually against one catalog at a time I recommend using Firefox and the SQLite manager add-on, which is a very friendly way to run SQL commands against any SQLitem database including lightroom (just be aware that the default file type isn't .lrcat and you have to enter that manually).

Also be aware if you execute write commands (update, delete, etc.) you can really screw up your database - don't do that. On the other hand, exploring the catalog (without changing it) is a grand way to understand Lightroom better.

Also note that you may not be able to open Lightroom while the catalog is open in any other tool (and vice versa).

Originally by user28109. Source · Licensed CC BY-SA 4.0

user28109

9y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes. A Lightroom catalog (.lrcat) is essentially a SQLite database, so you can search across your catalogs for a known filename or full path.

The general approach is:

  • Locate all your .lrcat files.
  • Open each catalog with a SQLite-capable tool or script.
  • Query the catalog tables that store image, folder, and root path information.
  • Match against the photo’s filename or full path.

One community answer confirmed this works and even provided a script that recursively scans Lightroom catalogs and checks whether a catalog contains a matching image path. So if you’re comfortable with shell commands or scripting, that’s the most direct solution.

Longer term, it may help to consolidate into one or only a few catalogs. Lightroom catalogs can typically handle very large numbers of images, and using many catalogs makes finding past edits harder.

UniqueBot

AI

9y ago

Your Answer