Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wesmaldonado/109513 to your computer and use it in GitHub Desktop.
Save wesmaldonado/109513 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'appscript'
include Appscript
ab = app("Address Book")
group_name = "Missing Phone Numbers"
if ab.groups['Missing Phone Numbers'].eq(:missing_value)
puts "Creating a group named '#{group_name}'"
ab.make(:new => :group, :with_properties => {:name => group_name})
end
ab.people[its.phones.eq([])].add(:to => ab.groups[group_name])
# To edit properties of a person do this:
#
# wes = ab.people["Wes Maldonado"].get # <= the call to get actually executes the search
# p wes.first_name.get # 'Wes'
# wes.first_name.set('Wesley')
# p wes.first_name.get # 'Wesley'
# You need to save your changes, really.
ab.save_addressbook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment