Changing the Location of Referenced Folders in iPhoto

If you use Referenced Folders in iPhoto there will probably come a time when you want to move the folders with the photos in them to another location. An example would be moving them to an external drive.

There isn't a nice method for updating the locations of the referenced folders through iPhoto after moving the folders - when you open the iPhoto library after moving them, iPhoto will still show the photos and their thumbnails, but when you try and view the full image it will complain that it can't find it and ask you to locate it. Rather a pain when you need to locate each image in your library.

The easiest way to fix the references is to modify the iPhoto database directly to update the path. I'd suggest you backup the iPhoto library before performing the steps below so you can easily restore it if you don't quite get it right. Also make sure iPhoto is not running when you are performing the database updates...

iPhoto stores its information in a sqlite database located in the folder (replace path_to_library with the location of your iPhoto library :
<path_to_library>/iPhoto Library.photolibrary/Database/apdb

The table with the folder locations for the images is RKMaster. You can see the image locations from a Terminal using:

cd <path_to_library>/iPhoto Library.photolibrary/Database/apdb  
sqlite3 Library.apdb 'select imagePath from RKMaster LIMIT 4'  

This will return the first 4 rows in the table, looking something like:


For this example, I am moving the referenced folders from /Users/myuser/Pictures to /Users/Shared/Pictures.

To change the location of the referenced folders in iPhoto, run an update against the table as per below. Change the paths in the replace arguments as required for your case.

cd <path_to_library>/iPhoto Library.photolibrary/Database/apdb  
sqlite3 Library.apdb "update RKMaster set imagePath = replace(imagePath, 'Users/myuser', 'Users/Shared')"  

You should now be able to open iPhoto and when you navigate through to the Photos in your referenced library and view the full photo it should work.

There's further information and more detail on steps in a post on the Apple Support Communities about Referenced Libraries