Modify Address Book IM handle from Jabber to Skype - help pls!

With Lion, address book now supports ‘skype’ as an IM handle. In previous imports, when skype wasn’t yet supported, I’d simply imported my skype users as jabber users (as a place holder).

Now, I’d like to change all jabber handles in my addressbook to skype handles, but my script isn’t working. Any help would be hugely appreciated.

Seudo code:

  1. find all contacts that have jabber IM handles
  2. create new skype handle with the properties of the old jabber handles
  3. delete old jabber entry
  4. save

I’ve searched the web and tried to put some code together, but it’s flawed of course:


tell application "Address Book"
	set thePeople to every person whose Jabber handles is not {}
	repeat with eachPerson in thePeople
		set Jabbernr to value of Jabber handles of eachPerson
		set skypeid to (item 1 of Jabbernr)
		make new Skype handle with properties {label:"Home", value:skypeid}
	end repeat
	save
end tell

I would really appreciate any help anyone could provide!

Hi, hallpower. Welcome to MacScripter.

I don’t have Lion yet, but this may do what you want, assuming that each person only has one Jabber handle to convert. I’ve treated the Jabber handle lists and the people IDs as parallel lists because I can’t get your ‘people whose’ filter to work in Snow Leopard:


tell application "Address Book"
	set {theIDs, theJabberHandles} to {id, Jabber handles} of every person
	repeat with p from 1 to (count theJabberHandles)
		set theseJabberHandles to item p of theJabberHandles
		if (theseJabberHandles is not {}) then
			set thisJabberHandle to item 1 of theseJabberHandles
			set skypeid to value of thisJabberHandle
			make new Skype handle at end of Skype handles of person id (item p of theIDs) with properties {label:"Home", value:skypeid}
			delete thisJabberHandle
		end if
	end repeat
	save
end tell

Thanks a million Nigel for giving it a shot!

For some reason it gave me a

, referring to “handle” in line 8:

make new skype handle at end of Skype handles of person id (item p of theIDs) with properties {label:"Home", value:skypeid} 

What do you recon?

The same compilation error occurs on my machine, but that’s because there’s no such thing as a ‘Skype handle’ here! I took the term from your post at the top of this thread. Did you find it in Address Book’s dictionary?