Cleaning up iPhoto

The longer I use iPhoto, the more I hate it. When I initially started using it, I would import photos but choose not to copy the originals to the iPhoto Library. In the past year or so, I’ve started to just allow iPhoto to copy the originals to the iPhoto Library. So now, I ended up with photos scattered all over the place. This was a pain to maintain and figure out where my photos were.

I decided that I want all photos to be in one place and if I was going to use iPhoto, I’m going to import by copying the originals to the iPhoto Library. Before I could get all of this to happen, I had to backup all of existing photos that were not in the iPhoto Library to an external hard drive. Planning on importing these photos over again from the external hard drive, I then deleted all of these photos through Finder. Going back into iPhoto, I still saw the thumbnails for the photos I just deleted. If I attempt to open any of them though, it complained it couldn’t find the original. What a mess. There doesn’t seem to be a way to refresh your iPhoto Library and it would remove photos it doesn’t have references to any more.

I figure the easiest way to get my iPhoto Library setup the way I want it is to start from scratch. So I went under my Pictures directory and renamed iPhoto Library to iPhoto Library.original. Opening up iPhoto again, you get prompted to search for your Library or create a new one. I choose create a new iPhoto Library and now I can begin importing my photos.


After making sure I have the option to copy items to iPhoto Library when importing, I can now import photos from my external hard drive.

Great! Now I have all of my scattered photos in iPhoto Library. But what about the photos I had imported to the original iPhoto Library ( the ones under iPhoto Library.original)? Well, there didn’t seem to be an easy way to import non-broken originals form one iPhoto Library to another from the GUI so I went to the command line.

All of the original photos that are imported to an iPhoto Library are under a folder called Originals. However, due to the way iPhoto manages the photos, this also includes the broken files that reference the photos I had deleted. Basically I wanted to get rid of all of these broken references before importing all of the photos from my original iPhoto Library to the new one I am creating. Here’s how I did it.

  1. Open up Terminal
  2. Change directory to the original iPhoto Library’s Originals directory (~/Pictures/iPhoto Library.original/Originals)
  3. The broken references aren’t actually symbolic links. They seem to be using extended file attributes to denote where the original file actually is (see xattr).  Since we deleted the actual photos, to identify these files type:
    find . -size 0

    to get a list of all of the 0 byte files.

  4. To remove them:
    find . -name "*.jpg" -size 0 -exec rm {}  ;

    or if you want to just move them elsewhere:

    find . -name "*.jpg" -size 0 -exec mv {} $dest ;

    where $dest is the path to where you want to move the files

  5. To delete all of the empty directories (that represent your events) for clean up purposes:
    find . -depth -type d -empty -exec rmdir {} ;

Now your original iPhoto Library should only contain photos that were imported by copying the originals to the iPhoto Library.

To finish importing everything, open iPhoto, choosing your new iPhoto Library and import the Originals directory from the original iPhoto Library (~/Pictures/iPhoto Library.originals/Originals). You might have to copy this folder someplace else since the Import menu doesn’t allow you to specify going into the iPhoto Library.originals package.

After about 5 hours of battling with iPhoto, I think I finally have all of my photos reimported to a fresh iPhoto Library with no duplicates and broken file references. Having to do all of this really makes me think to just switch to something else. How do you guys feel about iPhoto? What are some good alternatives? Picasa anyone?

Cleaning up iPhoto

7 thoughts on “Cleaning up iPhoto

  1. Theo,

    I am currently using Aperture 2.0, and it’s pretty good. It may not be $200 worth of good, though. I liked the Adobe Bridge / Lightroom combination for RAW workflow, but something about it felt a little too clunky for me.

    I’m sticking with Aperture for a bit since the RAW workflow is pretty streamlined. Tagging pictures is a royal pain in the ass, though. Why does nobody get the metadata part right? Apple offers a free 30 day trial if you wanna give it a go.

    1. Thanks Pete, I actually am trying out Aperture out right now. It imported all of my photos from iPhoto nicely. It takes forever to generate the thumbnails/previews it needs. My iPhoto Library is only 24 gigs and Aperture’s library is 9 gigs after importing the photos. I assume that means there’s 9 gigs worth of thumbnails and previews it generated. I really like the simple layout for event browser. The showslide feature is a little slow to start. I’ll have to try it out over the course of the next couple weeks and see how it goes.

  2. Andy says:

    Great post. First hit on Google and exactly what I was looking for. I’m in precisely the same spot. I’ll let you know how it turns out.

    Issues I’ve run into (on my test run as I haven’t yet imported stuff back into iPhoto, yet.):
    1. You have to try both cases of “*.jpg” and “*.JPG” as I’ve used two different cameras to use two different cases in naming their files
    2. I have (unfortunately) .asf files that I needed to convert before re-importing them into iPhoto as it didn’t catch them the first time round. Once I use the new QuickTime feature (that used to only be in Pro before Snow Leopard) to save them to .mov, iPhoto will note them in it’s library.

    I’ll let you know how it turns out. Thanks for sharing the knowledge!

  3. Andy says:

    It worked perfectly. I did have to go back and redo lots of the event renaming, re-organizing, and minor edits like rotating that I had done with the original, but that is understandable. Thank you again for posting this tidbit as it saved me hours!

  4. Name says:

    FYI: for the person worried about the case of jpg (jpg or JPG): use the -iname flag for case insensitive filenames.

    find . -size 0 -iname “*.jpg”

  5. bridgendmorgan says:

    I think I’m going to try Aperture and forget iPhoto. There seems to be a whole wave of problems with iPhoto that I can’t find answers to. As far as the fixes are concerned they all seem to be overly complicated.

    John M

  6. Andy says:

    Here’s the bash script I’m using to sync my iPhoto files to my wife’s Windows machine. Replace the user:password with a valid one for the Windows machine. Also replace the user names (my user’s name is Andy and my wife’s, Megan) with your own. Change the Windows computer name as appropriate. My geeky leanings toward Lord of the Rings results in my wife’s computer being named “Gimli”. My next modification will be to rsync over the videos to the Window’s “Videos” folder that iPhoto pulls of my camera as well.

    Thanks again for the post!

    #! /bin/sh

    find ~/Pictures/iPhoto Library/Originals/. -ipath *.jpg | sed -e ‘s#/Users/andy/Pictures/iPhoto Library/Originals/.##’ > ~/originals.txt
    find ~/Pictures/iPhoto Library/Modified/. -ipath *.jpg | sed -e ‘s#/Users/andy/Pictures/iPhoto Library/Modified/.##’ > ~/modified.txt

    grep -ivf modified.txt originals.txt > unmodified.txt

    mkdir ~/destination
    mount -t smbfs //user:password@gimli/Users/Megan/Pictures ~/destination

    rsync -aqr –files-from=unmodified.txt ~/Pictures/iPhoto Library/Originals/. ~/destination
    rsync -aqr –files-from=modified.txt ~/Pictures/iPhoto Library/Modified/. ~/destination

    umount ~/destination

    rmdir ~/destination
    rm ~/modified.txt
    rm ~/unmodified.txt
    rm ~/originals.txt

Leave a Reply

Your email address will not be published. Required fields are marked *