Lately I’ve been working on mailing out wedding invitations. The easiest way to print address labels on OS X is to select contacts or a group in Address Book, hit print and change the Page option to “Avery Standard” then select the label type. Easy. The hard part is getting all those addresses in there in the first place and then organizing them. My problem was that I imported things incorrectly a number of times and filled my address book with 1500 or so broken contacts. That made it really hard to call someone because I had 15 very similar looking entries for each person. Fortunately all the addresses I imported were missing phone numbers, so I knew I could group them together easily (with a smart group) but how could I script the name edits like “Add ‘& Guest’ if the name doesn’t include an &”? Not to mention I didn’t want to end up with contacts like “Joe Smith” next to one named “Joe Smith & Guest”!
First I tried to do this with AppleScript and 25 minutes into it had something working, but working with AppleScript is so strange, I needed ruby! In 10 minutes I had the following script written and now I could also use ruby to push/pull/stretch and tweak all the data I have in Address Book already, yay.