So I recently acquired a new mobile phone (a Samsung D500) and in general I’m very pleased with it. It doesn’t iSync, but it does talk Bluetooth, which is better than nothing. Unfortunately, it doesn’t accept a bulk vCard with more than one name – it only sees the first entry in any vCard. So to back up my phonebook, I have to export each card individually from Address Book, send them all, and accept them individually on the phone.

This sounds like a hassle but it’s really not so bad – I’m only doing it for my whole phonebook once, after all.

However, there’s a problem: though it exports vCards correctly, it displays names as Surname Firstname – this is the order they appear in a standard vCard. My old Sony Ericsson T610 also used the vCard format correctly, but displayed names as Firstname Lastname, which is how I prefer to search. So: there’s got to be an easier way than editing each name on the phone, or completely messing up my Apple Addressbook (which also displays Firstname Lastname).

There is. Enter BBEdit.

I’d already planned on using a regular expression, but unfortunately my development skills are still nascent, especially when it comes to file-handling. Trying to handle a directory of files and alter them each in turn was consuming a few more brain cells than it should.

Then I remembered that BBEdit has an option in “Search and Replace” marked Use Grep. It also has another handy feature: “Multi-File search”. So the obvious option was to write the expression in BBEdit, using its Grep functionality, and then apply it to a whole folder of files. Here’s how (with over-long explanation):

Search string: N:(.*;)(.*;);;

Replace string: N:\2\1;;

So, what this does: it’s a regular expression that matches anything along the lines of: N: (any number of characters then a semi colon) (any number of characters then a semicolon);;. It’ll find anything that matches that string.

Then, it applies the replace string to the selection it has matched. This string is reverses the order of those two bracketed atoms (as indicated by the \1 \2 in the replace string).

In short: it swaps the first and last name in the vCard. Then, you’ve got a folder full of vCards, and you simply select all and choose “Send Via Bluetooth”. The laptop will send them as fast as you can click “accept” on your phone. This is particularly useful for Motorola and Samsung owners and, best of all, if you run the grep-search on a file from the phone, it’ll convert the file back to correct lastname-firstname order. Obviously, this method will also work (with perhaps minor alterations) with any other text editor that can handle regular expression search and replace.

2 comments on this entry.

  • Vicki | 10 May 2005

    ooh. i’d forgotten your new phone. it’s very pretty indeed, as i recall… none of the technical stuff means anything to me at all, but i do remember spending a lot of time going “ooh” at it. :)

  • atomicjam | 12 May 2005

    ahhhh its a samsung! dont plug it in tom it might set on fire! *cough* SPV 500 *cough* can play doom/quake on my phone \o/