Putting AddressBook Smart Groups on the iPhone

iPhone really needs a search mechanism.  I’ve used mine since launch day and one thing I really do miss from my BlackBerry is simple contact search. 

My iPhone has over 3000 contacts and scrolling by letter takes too long.  A simple solution was to create some new groups in the Mac “Address Book.”  That was great, but why not use “Smart Groups?” 

I setup several Smart Groups and got ready to sync.  That’s when I found out that the iPhone cannot sync Smart Groups.  What a pain!

My solution was to write an AppleScript to copy from the Smart Group “Smart Restaurants” to a “Dumb Group” called “Restaurants” which can be synched to iPhone.

Here’s my script:  (saved to /Library/Scripts/)


—“Copy from Smart to Dumb.scpt”
— Description: Dumps Address Book Smart Groups to Dumb Groups
— by: David F. Bills 09.29.07

tell application “Address Book”
if not (group “Restaurants” exists) then
  make new group with properties {name:"Restaurants"}—Create our ‘hard’ Group if missing
end if
save addressbook
set smart_Rest to id of every person in group “Smart Restaurants”—This is the name of the Smart Group
set hard_Rest to id of every person in group “Restaurants”—This is the name of the ‘hard’ Group
repeat with sr in smart_Rest
  if hard_Rest does not contain (contents of sr) then add (every person whose id = sr) to group “Restaurants”
end repeat
save addressbook
end tell

Seems to be faster to run this from the shell script than in Script Editor and it makes sense to use osascript since I’m calling via Cron at 3am nightly.

0     3     *    *    *    osascript /Library/Scripts/Copy from Smart to Dumb.scpt

Now, I just need to do my daily sync first thing in the morning and I’m up to date.  Thanks to Craig Smith and Niel for their assistance.

You must be logged in to comment on this post (damn those spammers)

Already registered?

Username

Password

forgot password?       register