Is there a script to do this already? I can’t find it, maybe it’s because I don’t know what to call it. I don’t have any programming skills so I’m hoping to find something already made.
It’s necessary because even the Palm OS 5 still does not have work and home address fields, and it’s the work address that does not get transferred from the Address Book to the palm. Only the home, so you have to label the work address as the home address, and you can’t have two unless you use the Custom fields or the note field for the second address. I can’t be the only one who thinks this is crazy, can I?
Here’s a script that should help. First, select just the contacts you want to update, then run the script. The script will then prompt you about whether you’d like to swap the labels of the home & work addresses (makes the home address the work address & vice versa) or just update the home address to the work address. This works by changing the address label:
property home_label_localized : "home"
property work_label_localized : "work"
tell application "Address Book"
activate
set swap_labels to (button returned of (display dialog "Do you want to swap the home and work address labels for the selected contacts or just update home labels to work?" buttons {"Cancel", "Swap", "Update"} default button 3 with icon 1) = "Swap")
set home_people to (get selection)
repeat with this_person in home_people
tell this_person
try
if swap_labels then
set home_address to (item 1 of (get addresses whose label = home_label_localized))
set work_address to (item 1 of (get addresses whose label = work_label_localized))
set home_address's label to work_label_localized
set work_address's label to home_label_localized
else
set home_address to (item 1 of (get addresses whose label = home_label_localized))
set home_address's label to work_label_localized
end if
end try
end tell
end repeat
save addressbook
end tell
meanwhile I got a friend to do it for me, and here’s what he used:
tell application “Address Book”
set newGroup to make new group at end with properties {name:“Made Address Label Home”}
set thePeople to the people
repeat with aPerson in thePeople
if the (count of addresses in aPerson) = 1 then
set the label of the address of aPerson to “home”
add aPerson to newGroup
end if
end repeat
end tell
We had already fixed anyone with two addresses or more.
Hi Jon, this is a quite an old post and I wonder if you are still receiving notifications to comments.
I would like to modify your script (which btw, works like a charm) in order to swap first name and last name in my address book as I have many many entries that have been imported over the years from different databases and show up displaying name and surname the wrong way.
You don’t need a script for this. In Address Book, select the card or cards whose first & last name fields need to be swapped. Then, from the menu bar, select Card > Reorder Last Name Before First. That should do it. Tested with Address Book in Mac OS X 10.5 & 10.6.