How to bulk-edit Address Book, in particular to split the contents of First Name into First Name, Last Name

contacts

Following a MobileMe import of a Windows XP AddressBook legacy, there are hundreds of entries in the Mac Address Book like this:

First: Harry Potter
Last:
First: Fred Flintstone
Last:

It appears that what happened is that both the First and Last names in the Windows XP Address Book migrated to the Firstname field in Mac Address Book.

Is there a way to bulk-edit these? Going through the GUI means click on first name, highlight tail, cut, click on last, paste, next. It would be nice to do that in a text editor or with a wee perl script.

Can the Address Book be exported as structured text and subsequently replaced by modified structured text?

Best Answer

If you are comfortable with AppleScript, you should be able to get it done using this web page as a starting point: http://hints.macworld.com/article.php?story=20070813135408868

Otherwise, you can export one or more cards in the vCard format, open that up in a file editor and it looks like a properly separated name field looks like this: "N:Smith;Joe;;;" so if yours look like "N:Joe Smith;;;;" and you are comfortable with regular expressions you should be able to work out a search and replace that would look for 'N:(word1) (word2);' and replace it with 'N:(word2);(word1)'. I think that would give you the right number of ';'.