Adress Book | switch first and last name

I’ve let Adium ad my msn contacts to address book, but the first and the last name is switched.
I’ve tried to write a script to fix this, but it doesn’t work jet.
What am I doing wrong?


tell application "Address Book"
	set personsList to selection
	if ((count personsList) is 0) then
		display dialog "Nothing selected!" with icon caution buttons {"Drat"} default button 1
		return
	end if
	repeat with thePerson in personsList
		set theFirstName to last name of person
		set theLastName to first name of person
		set first name of person to theFirstName
		set last name of person to theLastName
	end repeat
end tell


Hi,

your index variable is thePerson but you use person.


.
repeat with thePerson in personsList
	set theFirstName to last name of thePerson
	set theLastName to first name of thePerson
	set first name of thePerson to theFirstName
	set last name of thePerson to theLastName
end repeat
.

Ok, I don’t get an error anymore.

But in Address book, the front and back name aren’t switched.
Do I have to add an extra line to save changes or something?

the changes aren’t visible immediately when Address Book is open,
but should appear when you reselect one of the items

Yes they do!
Thanks for the help!