All pastes #594917 Raw Edit

Untitled

public text v1 · immutable
#594917 ·published 2007-06-29 05:33 UTC
rendered paste body
tell application "Address Book"
	repeat with i in every person
		--backup phones
		set valueset to (value of phone of i) as list
		set labelset to (label of phone of i) as list
		--remove all phones to readd latter
		delete every phone of i
		
		--make the modifcations to the phones before readding
		set x to 0
		repeat until x = (count of every item of valueset)
			set x to x + 1
			set address_text to item x of valueset
			if character 1 of address_text is "1" then
				set address_text to "+" & address_text
			else
				if address_text does not contain "+1" then
					set address_text to "+1" & address_text
				end if
			end if
			set item x of valueset to address_text
		end repeat
		
		--readd phones
		set x to 0
		repeat until x = (count of every item of valueset)
			set x to x + 1
			make new phone at end of phone of i with properties {label:(item x of labelset), value:(item x of valueset)}
		end repeat
	end repeat
	save addressbook
end tell