Mac OS X

Reading Address Book from the Command Line

There isn’t an easy-to-use command line interface to the Address Book. You can use AppleScript with it, but not necessarily the command line. This isn’t to say there isn’t an AddressBook framework waiting for someone to use it. Well, Scott Stevenson posted a tool on his blog, Theocacao.

This tool is pretty rudimentary but can be useful for a few basic tasks, and provides a nice framework for the development of a larger tool. Basically, abtool has one positional parameter – a search string. Using that it will look for a pattern in the name. It doesn’t search any of the other fields, use wildcards, nor allow for changing of any of the information in any of the fields. But it does give you the ability to pull a phone number and email address for a user who matches your query. Overall it’s a nice little tool that allows you to do something you otherwise might need to use osascript to do.