Skip to content

Hacking the Adobe Lightroom Catalog

I had a problem the other day.. I wanted to moved all my Photographs from my workstation to my server, and access them over the network. The main issue is that I keep all of them organized in Adobe Lightroom catalogs (v. 1.4.1), and it does not allow the catalogs to be in network drives. That’s not a big deal, as I prefer to have the catalogs local (just a couple of GBs) and the bulk of the files in the server (around 130 GBs).

Since I moved the files using a USB drive, the Catalog had all files referencing the location of the drive. So I first tried to “find missing folders” option to relocate them. Unfortunately it asks me to apply the changes to every folder manually, and that was too much work. Besides, it was renaming the folder entry to “/new-path/date”, which looks very ugly and renders the folder browser in the library useless.

So I started to look for another option. Fortunately, the Lightroom catalog file (.lrcat) is a regular SQLite database file. So I took my database browser and after a few minutes inspection, I came up with the following two commands:

UPDATE Adobe_imageFiles
SET absolutePath = replace(absolutePath,"old-path","new-path");

UPDATE AgFolderTagInfo
SET absolutePath = replace(absolutePath,"old-path","new-path");

the catalog keeps the absolutePath of every image in a table, and the first update replaces the old path with the new one. Similarly, it keeps every folder path in another table, and the second query takes care of it.

For best results backup before doing any changes, and tell Ligthroom to optimize the catalog after reopening.

One can do some other stuff too, like remove “missing file” tags, or correct filenames for images. For example, let’s suppose we want to check the entries of missing files:

SELECT * FROM Adobe_imageFiles where markedMissing is not null;

then we can clear it with:

UPDATE Adobe_imageFiles SET markedMissing=NULL where markedMissing is not NULL;

in addition, Lightroom will add a tag to the image, which is the kindName ‘AgMissingFileTagKind’. You can find the tag at AgLibraryTag and applied to the image at the AgLibraryTagImage:

SELECT * FROM AgLibraryTag where kindName = 'AgMissingFileTagKind';
SELECT * FROM AgLibraryTagImage where tagKind = 'AgMissingFileTagKind';

The last one links the tag to the imageID. You only need to remove the corresponding entries in the table to remove the “missing” flag from a file, as well as to remove the ‘markedMissing’ flag.

It is similar for the Folders, using the AgFolderTagInfo table and the same AgLibraryTag and AgLibraryTagImage, but of kind ‘AgMissingFolderTagKind’.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*