Address Book AppleScript example

Here’s a simple AppleScript that exports all of the email addresses in your Mac OS X address book as a comma-separated list:

tell application “Address Book”

set emailList to {}

set peopleCount to (count every person)

repeat with i from 1 to peopleCount

set emailList to emailList & (get value of every email of person i)

end repeat

set outputFileName to choose file name with prompt “Save address book as text:” default name “addressbook.txt”

set outputFile to open for access outputFileName with write permission

repeat with e in emailList

write e & “, ” to outputFile

end repeat

close access outputFile

end tell

Join the Conversation

3 Comments

  1. Hi Paul,
    I wonder if you could help? I have just imported an few hundred contacts from an Outlook export into an existing Address Book. Address Book generally did a good job of merging the content but for some reason it hasn’t managed to match up “EmailAddress:” with an email field in Address Book. So instead it has put it into the Notes field like this:

    EmailAddress: [email protected]

    Could you help me with writing a script that will look through all contacts and where “EmailAddress: [email protected]” appears, the script re-writes the address into an email field in the contact?

    Any suggestions of how I might achieve this would be very welcome.

    Many thanks,
    AYworld

Leave a comment

Your email address will not be published. Required fields are marked *