One way to sync Address Book smart groups to iPods etc.

For all of you who use your iPods to get you address book contacts here is a way to get the smart groups on them.

I got my iPod touch last week, and I realized that, even if it can sync my contacts and groups correctly from Address Book, it cannot sync smart groups. While it is possible to manually copy contacts from a smart group to a standard group, that is boring.

So, I decided to get myself to AppleScript, and built a little script that will help. For the script to work, it is simple: create your smart group and call it, let’s say, SMyGroup (The “S” before meaning smart; otherwise name the group as you want). Built the smart group conditions to make it work the way you need. Then create a standard group called MyGroup. So you have two groups with similar names, with only a “S” in difference. That is necessary because I couldn’t figure out how to distinguish smart from standard groups in Address Book via script. Then use this script:

tell application “Address Book”
repeat with the_person in every person in group “SMyGroup”
add the_person to group “SMyGroup”
end repeat
save addressbook
end tell

Repeat those steps for each smart group to be put into a standard group, and in the AppleScript, just add more repeat loops. Execute it in AppleScript Editor, and your smart and standard groups will be identical, and will sync correctly to your iPhone or touch.

As a bonus hint, you can automate this in Automator. Open the application, and put an Automator » Run AppleScript action into the workflow area, and paste the above code there. Then save it as an iCal module and set it to execute, say, every day at 8:00 repetitively. Then, if you make a change on your computer or iPhone or Touch, you’ll always have a fresh copy the of changes in all of them. Cool!

Technorati Tags: ,

Comments are closed.