Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cookieme

macrumors regular
Original poster
Aug 22, 2005
156
1
Hi

I came across a script online which I've altered a bit for my needs. This is my first dabble with AppleScript and I would appreciate any feedback on how it can be improved in terms of structure and any best practices. I'm running this on Snow Leopard 10.6.2.

Code:
tell application "Address Book"
	set phoneList to {}
	set peopleCount to (count every person)
	repeat with i from 1 to peopleCount
		set phoneList to phoneList & (get value of every phone of person i)
	end repeat
end tell

set outputFileName to choose file name with prompt "Save phone list:" default name "addressbook-phonelist.txt"

set outputFile to open for access outputFileName with write permission
repeat with p in phoneList
	write p & (ASCII character 10) to outputFile
end repeat
close access outputFile

Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.