Today, I went through one of my old Aperture libraries and fixed some of the corrupted image entries. This post addresses the specific case of referenced files in Aperture spontaneously pointing themselves at other images on the disk. In my case, I opened up an old library from 2 years ago, and 61 images spontaneously pointed themselves at images I took just a couple months ago. I didn't have time to manipulate the SQLite database directly, so I had to re-import the corrupted images manually.
The goal was to re-import all of the corrupted images and copy metadata and adjustments settings from the old corrupted images to the new (duplicate) images. Here's how I did it:
1. Create an Aperture album containing all of the corrupted entries. Corrupted entries can be identified visually or by other means.
2. Move all of the corrupted files to a new folder (physical location, in Finder).
3. Re-import the corrupted files folder into Aperture by reference.
4. Add the newly-imported images to the corrupted entry album.
5. View in list form and sort by filename. Now, you should see corrupted images and their replacements. Each corrupted image will be followed by its replacement image (or vice versa).
6. Select each corrupted image, hit SHIFT-COMMAND-C to Lift Metadata & Adjustments, select the newly-imported image, and hit SHIFT-COMMAND-V to Paste. This can be done really quickly with the keyboard.
7. Sort by import session, select all corrupted images, and hit COMMAND-DELETE to delete them from the library.
Note that step 2, above, can be extremely time consuming. I used a shortcut to do this:
1. Export all of the corrupted entries to a folder (I used 640-pixel images). The export settings are not important -- we just need the filenames.
2. Use Terminal to get a list of the files in the folder. I used "ls -b > filenames.txt".
4. Edit filenames.txt and manipulate the text to create the Terminal command, "mv file1.cr2 file2.cr2 ... fileN.cr2 foldername". I did this by doing a RegExp replacement of ".jpgn" to ".cr2 " because the exported filenames were all jpgs, and my originals were Canon RAW files (cr2). If I were better at shell commands, I'm sure I could have used pipes and magic to do this in one line.
5. Run the move files Terminal command you created while in your RAW files directory, and it should move all of the replacement images to the new folder.
The shortcut assumes that all of your RAW images for the project are in the same folder. Mine weren't, so I had to select of my RAW images in Aperture and use *File->Relocate Masters* to move them all to the same folder.
I desperately need to migrate all of these projects to Lightroom, but some of them are meticulously keyworded hierarchically. Since Aperture can't export keywords while preserving hierarchy, I am screwed.