Created
August 3, 2010 06:13
-
-
Save markbao/505929 to your computer and use it in GitHub Desktop.
This will allow you to sync your Mac OS X Address Book with Pine. It'll take a few seconds if you have a few hundred contacts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- adapted from http://forums.macosxhints.com/showthread.php?t=17762 but it actually works here | |
tell application "Address Book" | |
set pineBook to "" | |
-- Count people as we loop over all of the people in each group | |
set i to 1 | |
repeat with thePerson in every person | |
-- Check that there are e-mail entries for this person | |
if email of thePerson exists then | |
set theName to (name of thePerson) as string | |
-- Output every e-mail address entered for this person | |
set j to 1 | |
repeat with theEmail in emails of thePerson | |
set theEmailAddress to (value of theEmail) as string | |
set pineBook to pineBook & (theName & tab & theName & tab & theEmailAddress) as string | |
set pineBook to pineBook & (" | |
") as string | |
set j to j + 1 | |
end repeat | |
end if | |
set i to i + 1 | |
end repeat | |
-- Output to file ~/.addressbook | |
set pineBookFile to (((path to home folder) as string) & ".addressbook") | |
try | |
set the openPineBookFile to open for access file pineBookFile with write permission | |
set eof of the openPineBookFile to 0 | |
write pineBook to the openPineBookFile starting at eof | |
close access the openPineBookFile | |
return | |
on error | |
try | |
close access file pineBookFile | |
end try | |
-- Dump the result if there is a file error | |
return pineBook | |
end try | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment