If you use Address Book and Mail, hopefully you’re taking advantage of Address Book’s ability to create groups and smart groups. Groups in Address Book can be used in Mail by name—making it easy, for instance, to send an email to all your relatives, your group of friends from college, or any other collection of people you’d care to create.
To make a new group in Address Book, choose File -> New Group or File -> New Smart Group (or just use the plus sign at the lower left corner; hold Option and it changes to a gear icon for a new smart group), give it a name ( The Family ), and then drag the desired contacts into the group (or set the conditions for a smart group). Then in Mail, when you’re creating a new email, you can address it to The Family , and all the relevant email addresses will appear.
But help with creating and using groups in Address Book and Mail isn’t really the subject of today’s hint. Instead, the objective today is to identify those Address Book contacts who may not yet be in any groups. You may, for instance, have missed Uncle Ned when creating your My Family group, and it’d be a shame if he didn’t see the invitation to the upcoming family reunion. But how can you make sure you included all your relatives in your group?
As you may already know, one way to check is to highlight a contact and then press the Option key. When you do, the groups to which that contact belongs will be highlighted in the Group column. While this works well enough for an individual contact, it’s not a really efficient way to check all 250 entries in your Address Book—plus you’d have to jot down those contacts who came up with no group affiliation. You might think you could use a smart group, but unfortunately, Group isn’t one of the criteria you can use to define a smart group’s conditions. But thanks to an insightful macosxhints.com reader, there is a relatively simple way to find all your ungrouped contacts: AppleScript.
Open up Script Editor, and paste in the following script:
property orphan : "Orphans"tell application "Address Book" try if group orphan exists then repeat with this_person in every person of group orphan remove this_person from group orphan end repeat else make new group at the end of groups with properties {name:orphan} end if save addressbook repeat with this_person in every person if number of groups of this_person = 0 then add this_person to group orphan end if end repeat save addressbook end tryend tell
The script is relatively self-explanatory, but here’s a bit more detail on how it works. The first line is the only one you need to edit; change Ungrouped
to whatever you’d like to name your new group, or you can leave it as is. Be sure to leave the quotes intact if you do change the name.
The first thing the script does is see if there’s an existing Ungrouped group; if there is, it deletes it to start fresh (the version of this script posted on macosxhints.com didn’t work in this way, but I was getting inconsistent results with it). The script then creates a new blank group and cycles through the your contacts, adding anyone without a group membership to the Ungrouped group.
After entering the script in Script Editor, save it somewhere convenient in your user’s folder, then click Run to test it out. If everything works, you should wind up with an Ungrouped group in Address Book. Open that group, and you can then easily see if Uncle Ned did, indeed, get passed over for the party invitation. Of course, the larger use for this feature is to insure that there aren’t any names in Ungrouped that you intended to include in one of your other “regular” groups. If you ever need to check for ungrouped entries in the future, just re-run this script, and you’ll have a fresh Ungrouped group to work with.