Forked from wesmaldonado/Scripting OS X Address Book with Ruby.rb
Created
September 1, 2016 07:50
-
-
Save tsboh/6d20bbae34dfdd786ced98f5fdec364e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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