Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • How To Backup And Manage Your iPhoto Library Manually

    Posted on August 7th, 2010 phpguru No comments

    If you have a Mac, chances are you love iPhoto. It’s probably the best program ever made for managing pictures. Now that your iPhone 3GS or iPhone 4 shoots video, you’ve got photos and pictures all mixed up together, and it’s not exactly easy to find the original photos on your hard drive. If you have a digital camera as well, like I do, then you have high resolution photos from your digital camera mixed in with lower resolution shots and videos from your iPhone.

    Here are some power user tips and tricks for managing and backing up your iPhoto library. If you’re using Time Machine, your hard drive is backed up automatically, but what if you want to back up your iPhoto library to a memory stick to transfer to a digital photo frame? This is where a manual iPhoto backup can come in handy.

    First question… Where does iPhoto store your original photos?

    It’s not exactly obvious. Open your Pictures folder, under your home directory:

    MacHD -> Users -> Your User Name -> Pictures

    iphotolibraryInside your pictures folder, you’ll see a special icon named iPhoto Library. It’s actually an Application Bundle or Package, a special type of folder in Mac OS X.

    Here’s Tip #1: Right click on iPhoto Library and choose Show Package Contents. When you do this, a new Finder window opens, and inside there you’ll see a folder called Originals. This is where all the goods are stored. Drag all the folders in here to a USB Hard Drive to backup your entire iPhoto library at any time.

    Let’s say you have a backup hard drive named Backups, and on that drive is a folder called Movies. It would be great to separate out all the movies stored in your iPhoto library to this Movies folder. We don’t want to move them, because then iPhoto will lose track of them.

    Here’s Tip #2: You can drag any folder from the Finder onto a terminal window to see its full path.

    For example, to find the Unix path to the Movies folder on your Backups hard drive, you just drag that folder into a terminal and you’ll see that the path is

    /Volumes/Backups/Movies

    In Terminal, type

    cd

    and press the spacebar.

    Then drag the iPhoto Library’s Originals folder to the Terminal. Afterwards, the entire command will look something like this:

    cd /Users/YourUserName/Pictures/iPhoto\ Library/Originals

    Now press return, and you’ll be inside of the iPhoto Library/Originals folder from Terminal. Note that any spaces in folder or file names are preceded by a backslash (“\”) in Terminal.

    Here’s Tip #3: Using the Unix find program, you can output your search results to a text file. Here’s how. At the terminal prompt, type:

    find ./ -name *.MOV -print

    This will show you (outputted to the Terminal window) all the movies under you iPhoto Library. What this command says is, find, under the current directory, all the files whose name ends with .MOV (yes, it is case sensitive) and then print it out (echo to the terminal window, not your printer.)

    You should see a list of only movies, inside all the various folders under your iPhoto Library. What we really want, though, is to store these full movie paths to a text file, so we can reference them later. So, the way to do that is using the greater than symbol (“>”) and then provide the name of a text file to create.  So the whole command to find movies and output the list to a text file goes:

    find ./ -name *.MOV -print > ~/movies.txt

    Now the tilde character (“~”), represents “my home directory”, so I’m asking Terminal to list all the movies under my iPhoto library, and save the output to a text file named movies.txt in my home directory.

    Here’s Tip #4: How to copy all the files listed in a text file to a new location. The unix command “cp” stands for copy. But in order to do a batch copy, we need to write a little one-line bash script. We’re going to use our Backup drive’s Movies folder as the target directory to copy the movies to. The script looks like this:

    while read file;do echo "$file";cp "$file" /Volumes/Backups/Movies;done <~/movies.txt

    Depending on the speed of your hard drive, the size and number of movies you’re copying, this could take a while. Let’s look at the script piece by piece to see exactly what’s going on.

    while read file;do
    ...
    done

    This while loop says to continue reading lines from a file as long as there’s more lines in file to read. The end of the while loop is the done statement at the end.

    echo "$file";

    This says to print (echo) the name of the file currently being copied to the terminal output window. Without this line, the script doesn’t look like it is doing anything… it still works, you just have no indication of what file is currently being copied.

    cp "$file" /Volumes/Backups/Movies;

    Here is the exact piece of code that actually copies the source file to the destination. Which source file? The one listed on the current line of the text file we’re currently reading from. Which text file?

    <~/movies.txt

    This says we want to use our list of movies (movies.txt) in our home directory (~/) as the input file (<).

    Thank goodness for great sites like unix.com where I found the inspiration for this post. I would’ve eventually figured it out, but their post saved me a ton of time and a lot of hassle. Hopefully this post will do the same for you, too.

    Leave a reply