Swap Address Book first/last names via AppleScript

Apr 05, '07 07:30:00AM

Contributed by: swaldoca

When I copy email addresses from Mail to Address Book, the order of names is frequently mangled, placing the last name in the first name space, and vice versa. As far as I understand, the Swap First/Last menu item only changes the display order, not the stored location of the data. (Ephramz previously posted a similar solution to a more difficult problem.)

This short applescript just trades the first and last names for the selected entries.

tell application "Address Book"
  set mySelected to selection
  repeat with myPerp in mySelected
    set tmp to last name of myPerp
    set last name in myPerp to (first name in myPerp)
    set first name in myPerp to tmp
  end repeat
end tell
I saved this in my Library » Scripts » Address Book Scripts. Ideally, I'd bind a hot key to it run it every time I come across a swapped name, but for now I just run it from the menu.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070403163155712