Have a peculiar problem with the Address Book script below, that I just cannot fathom.
almost 1000 entries.
Address Book script
tell application "Address Book" to launch
tell application "Address Book" to set unsortedList to name of every person
set {TID, text item delimiters} to {text item delimiters, linefeed & "|||"}
set theList to (do shell script "echo " & quoted form of (unsortedList as string) & "| sort -d -f")
set text item delimiters to TID
theList
Each time theList is returned there is one record returned without the preface |||.
I have deleted that record and replaced it with a replica.
But the next time the script is run another single record (not the replica) is returned without the preface |||.
And again and again.
Would very much appreciate any help.
Val
AppleScript: Version 2.3 (118)
Browser: Safari 533.16
Operating System: Mac OS X (10.6)
The retrieved list is always sorted alphabetically. So the record without my ||| marker is located all over the place.—perhaps in the order in which the records were entered.
Is there a way to remedy this ? I actually am not very skilled at this and rely mainly on scripts by others on this forum.
My intent is to write the list to a text file and then to replace the ||| marker with "pop1.option = " (for insertion into a Pashua dialog)* with a script I picked up at -http://macscripter.net/viewtopic.php?id=11374 by Julio.
*have done the insertion successfully into a Pashua dialog with a repeat loop but would hope that the alternative that I am currently considering would be faster when the Address Book database is very large.
I tested the actually sed and it didn’t work as you got it.
It did however work with a minor modification. I had a text file of 102 lines which were prepended with ‘|||’ then I removed the ‘|||’ from one line in the middle, and just ran this command (with its output ). As you can see I got appended an extra line solely consisting of ‘|||’ because the cat command added a linefeed after the last line or that sed did.