Tell me more ×
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

1 Answer

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

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.