#!/usr/bin/ruby

require 'osx/cocoa'
include OSX
OSX.require_framework 'ScriptingBridge'

iPhoto = OSX::SBApplication.applicationWithBundleIdentifier("com.apple.iPhoto")

photos = iPhoto.photos # .filteredArrayUsingPredicate(filter)
# using the predicate means photo.select fails. why??

photos.each do |photo|
  next unless photo.name == "DSCF1295"
  
  iPhoto.activate
  photo.select
  photo.assignKeywordString("flickr")
end