Serge's Answers
Sunday, July 20, 2014
Sunday, July 24, 2011
Fixing Missing files in Adobe Lightroom 3 in batch mode
I recently moved my photo collection to a different drive on my computer. Unfortunately, this caused all the files to show as missing in Lightroom 3.
Also, the files are displayed as hundred of different directories, so I would need to correct the folders one by one, a tedious process.
To make matter worse, the dialog in Lightroom to find a missing folder doesn’t remember the previous selection, so I would need to navigate again and again through the hierarchy to select the new repository.
I googled for a way to automate this process, but couldn’t find a satisfactory answer.
Then, trying to edit the catalog file by hand, I discovered that Lightroom uses a standard SQLite database, so we can edit the catalog with standard SQLite editors.
I used the following steps to correct all the folders in Lightroom from the previous location in “F:\Pictures\”, to the new location in “M:\Pictures\”:
WARNING: Be sure to first make a backup of your Lightroom Catalog. The following steps can lead to a corrupted catalog file if a mistake is made.
- Be sure that the Lightroom process is closed
- In Firefox, install the SQLite Manager Add-on
- After installing the add-on, open the SQLite Manager by selecting the menu “Tools / SQLite Manager”.
- In the SQLite Manager, select the menu “Database / Connect Database”, and select the Lightroom 3 catalog, typically in “C:\Users\My User Name\Pictures\Lightroom\Lightroom 3 Catalog.lrcat” (You will have to select the “All Files” from the combo box in the dialog, instead of the default “SQLite DB Files (*.sqlite;)” option)
- In the ‘Execute SQL’ tab of the SQLite Manager window, you can type the following command to see the list of roots that still start with the old path (“F:/Pictures” in my case):
SELECT * FROM AgLibraryRootFolder where absolutePath LIKE "F:/Pictures/%"
(You will need to enter the query above in the ‘Enter SQL’ text field, then press the ‘Run SQL’ button).
This query will produce a list of results in the window, such as:
"322791","4F289D5A-52EF-411E-9339-D7D59B3A9C3A","F:/Pictures/2004/Originals_3/","Originals_3"
"322803","F8A610AD-8D72-4937-B324-316149B70E5E","F:/Pictures/2906/Originals_2/","Originals_2",
If you do not obtain any result, it means that the pattern ("F:/Pictures/%" in my case) is incorrect.
To change all those roots, the following query can be executed in the same tab:
update AgLibraryRootFolder set absolutePath = replace(absolutePath, 'F:/Pictures', 'M:/Pictures') where absolutePath LIKE "F:/Pictures%"
This query will effectively updated all the rows in the table that have an absolute path that starts with “F:/Pictures” and update them so they start with “M:/Pictures” instead (my new picture location).
After doing this quick operation, you need to select the menu “Database / Close database”, then open Lightroom to see if there is still any missing files.
I my case, it worked perfectly.
DISCLAIMER:
I offer no guarantee whatsoever that those steps will not corrupt your Lightroom catalog, erase your data, hard drive, and make your computer explode in flames. Use this information at your own risk only.