How to fix folder names issues in Lightroom catalog?

I had a few sleepless nights after transferring my Lightroom 4 catalog from my old MacBook (which cannot be upgraded to Maverick) to a lightning fast new PC. I copied my Pictures folder and my catalog to my new PC and I realized that one-third of my folders were missing. Here comes the real story of fixing it.

Disclamer

If you do not understand what stands here, do not try to follow! 
Think before you type! 
Oh, and do not forget to create a backup!

How to migrate your catalog?

Copy over every image and your catalog (plus some additional files), configure your root Picture folder to Lightroom and you are set. In theory. In practice that did not work in my case. All right, there is another option. This should work. Instead of copying, I tried exporting my whole catalog as a catalog.. Exporting all the files over a network connection took almost half a day and at the end it didn’t help. By the way, you can find a good video about the theory here.

So, I tried to figure out what caused the problem and I soon concluded something that went wrong with the folder names. I was able to map the right folder manually inside Lightroom but that is not an option for few hundred folders.

Then I mapped my old folder over windows sharing to my catalog and nothing changed, what this meant is that HFS acts differently than NTFTS. So I’m suck. I cannot do it without hacking the right names into my Lightroom catalog.

Fortunately Lightroom catalog is a sqlite database, so you can manipulate it with standard tools.

Figure out the structure

I used sqliteman to search for the related data. As I opened the .lrcat file it quickly turned out that AgLibraryFolder table holds the folder names I need.

Renaming the folders

As you may have realized in the screenshot above, the problem is with the representation of á (and some other), so I needed to replace these characters with the appropriate ones. So, I opened the database with sqlite and dumped the table into sql script by the following commands:

.output aglibraryfolder.sql
.dump aglibraryfolder
.exit

After that I opened the file in Notepad++ and used the search and replace function to replace the strings. In your editor you should see something like this:



Now, we need to reload our library to sqlite and process our changes by doing the following:

drop table aglibraryfolder;
.read aglibraryfolder.sql
.exit

Finally, I was able to open my fresh new library with the proper file names. Easy, isn’t it?
  

egjegyzés