Monday 28 December 2009

Happiness is...

... your 4 year old nephew telling you he "loves his new Nintendo DS" while you're attempting to play "Mopoly" (as he puts it) with him.

Deleting Flickr Albums from iPhoto

(or, how to live dangerously with the command line)

So when I set myself up with a Flickr account I thought - hey, now I can really integrate and publish my photos through iPhoto, since that is where they are all managed.

iPhoto really does make it easy - select some photos, click the Flickr button and away you go. Drag photos in and out of the Flickr albums and iPhoto syncs automatically with flickr.com. Great.

Apart from when you now want to disassociate the Flickr albums in iPhoto from flickr.com. Sure, you can delete the Flickr albums, but that also deletes the sets on flickr.com as well.

I'm looking for a way to delete Flickr albums from iPhoto, but leave the pictures on flickr.com intact.

There is a way through iPhoto to delete all Flickr albums associated with one account:

  1. select a Flickr album
  2. click the settings button on the toolbar
  3. click the button to remove the account
  4. now delete all Flickr albums (iPhoto will complain about username and password, but that's OK)

But to disassociate individual Flickr albums doesn't seem possible from within iPhoto without deleting the sets from flickr.com. (If there is a way, please let me know!)

So, if you want to live on the edge and feel in the mood for some hardcore SQLite command line voodoo with the risk of totally screwing up your iPhoto Library, then read on…

Of course, usual disclaimers apply from now on - I'm not responsible for you losing your cherished wedding photos or baby pictures, so don't be dumb: make a backup before you continue. Time Machine is good enough for a backup, but to be honest, just copying iPhotoMain.db will probably suffice. If you're mad enough to follow my instructions, then let us continue...

So, open a new Terminal window and enter the following commands:

$ cd "~/Pictures/iPhoto Library" (or wherever it is)
$ ls -l

You should see a file called iPhotoMain.db

$ sqlite3 iPhotoMain.db
sqlite> select primaryKey,publishServiceKey,publishedName from SqPublishedAlbum;

This lists all published albums (MobileMe, Facebook, Flickr, etc.) Make a note of the primary keys (the numbers in the first column) of the albums you want to delete. Now the dangerous bit...

sqlite> delete from SqAlbum where primaryKey in (x,y,z,…)
sqlite> delete from SqPublishedAlbum where primaryKey in (x,y,z,…)

Where x,y,z,… are the primary keys you made a note of earlier.

sqlite> .quit

Close the Terminal window and restart iPhoto. The albums you deleted should no longer be in iPhoto, but will still be on flickr.com.

If you find that iPhoto crashes when it starts, then you may have just deleted the albums from the SqPublishedAlbum table, and not from SqAlbum as well. Try the SQLite commands again. You should also delete the iPhotoMain.db-journal file as well.

The same principles probably apply for other publishing services like Facebook and MobileMe, but I've not tried this method them.