Due to entry errors, I need to massage the phone numbers of a variety of entries in my Address Book. My script thus far does what I want by grabbing all the phone labels/numbers, re-ordering them and making the changes. However, I’m stuck now because I can’t get the old list of phone numbers and labels to vacate before I put the new data in place. Anyone have an idea or hint or bit of script to help me out, perchance?
Thanks! Michael
tell application "Address Book"
set PersID to selection
set PersName to (item 1 of PersID)
set foneL to label of phone of PersName
set foneV to value of phone of PersName
tell application "Finder"
activate
choose from list foneV with title ¬
"Swapping Phone List Order" with prompt "Swap which phone numbers?" with multiple selections allowed
set thePhoneNum to the result
end tell
tell application "Finder"
set newphoneorder to {}
set newphoneorder to newphoneorder & (item 2 of thePhoneNum)
set newphoneorder to newphoneorder & (item 1 of thePhoneNum)
end tell
set phoneID to {}
repeat with m from 1 to count of newphoneorder
repeat with l from 1 to count of foneV
if item l of foneV = item m of newphoneorder then set phoneID to phoneID & l
end repeat
end repeat
set firstfoneL to (item (item 1 of phoneID) of foneL)
set secondfoneL to (item (item 2 of phoneID) of foneL)
set firstfoneV to (item (item 1 of phoneID) of foneV)
set secondfoneV to (item (item 2 of phoneID) of foneV)
set (item (item 1 of phoneID) of foneL) to secondfoneL
set (item (item 2 of phoneID) of foneL) to firstfoneL
set (item (item 1 of phoneID) of foneV) to secondfoneV
set (item (item 2 of phoneID) of foneV) to firstfoneV
--delete label of phone of PersName
--delete value of phone of PersName
repeat with P from 1 to count of items in foneL
tell PersName to make new phone with properties {label:(item P of foneL), value:(item P of foneV)}
end repeat
save addressbook
end tell