Re: address book export to .addressbook file
Re: address book export to .addressbook file
- Subject: Re: address book export to .addressbook file
- From: pete boardman <email@hidden>
- Date: Sun, 4 Sep 2005 10:06:05 +0100
On 3 Sep 2005, at 05:29, Patrick Collins wrote:
After this information is extracted from addressbook, then I need to
modify the .addressbook file and add to it:
Nickname+(TAB)+Fullname+(TAB)+Fcc+(TAB)+Comment
A script to do this shouldn't be too difficult. A first approximation
is this (I have no idea whether the resulting file actually works
with 'pine'):
--
set rList to {}
tell application "Address Book"
repeat with p in people
tell p
set {elist, theNickName, theNote} to {{}, "", ""}
if (count emails) > 0 then
repeat with e in emails
set end of elist to e's value
end repeat
set AppleScript's text item delimiters to ","
set elist to elist as text
set AppleScript's text item delimiters to " "
end if
if nickname is not missing value then set theNickName to
nickname
if note is not missing value then set theNote to note
set end of rList to theNickName & tab & name & tab &
elist & tab & theNote & return
end tell
end repeat
end tell
set fileRefNum to (open for access ((path to desktop) as text) &
"addressbook" with write permission)
write (rList as text) to fileRefNum
close access fileRefNum
--
Apart from error handling (omitted), a possible problem here is that
the note field in Address Book can contain returns, whereas
presumably the addressbook file cannot. So they would need to be
processed.
Also, I would join this new file to the existing one after checking
them, rather than merge them in the script (I'm cautious about that
sort of thing...).
Pete
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden