Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Is there a CLI front-end to the Contacts.app (formerly Address Book.app) database?

Example:

mycontacts --email '*@google.com' # to get Googlers
share|improve this question

2 Answers 2

Contacts still has AppleScript support. You can see documentation for the supported properties and commands by opening its dictionary in AppleScript Editor.

osascript -e 'tell app "Contacts" to properties of people where vcard contains "@gmail.com"'

I didn't find a way to check the actual email fields using a single specifier.

set l to {}
tell application "Contacts"
    repeat with p in people
        repeat with e in (get value of emails of p)
            if contents of e ends with "@gmail.com" then set end of l to name of p
        end repeat
    end repeat
end tell
l
share|improve this answer
    
Thanks, upvoting because it's a solution to the actual query I requested but it isn't a generic solution so I won't accept just yet. –  Robottinosino Nov 25 '12 at 15:22

The closest thing to a generic solution is Shane Celis's contacts command available at http://gnufoo.org/contacts/. This is also available as a package in homebrew, which can be installed with: $ brew install contacts

There are other options that may also work for you. Contacts just stores info in a sqlite database so you can access it with the sqlite command. You could create a custom script to accomplish a particular task if you want.

Scott Stevenson had a tool called abtool up that was popular for a while, but it appears to be a dead link now. You might also try searching through some of the stuff on GitHub. In particular, since Shane Celis's app appears unmaintained (while still functioning well), there are some who are building replacements.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.