Fixing Mangled Contact Labels on iPhone

Image representing iPhone as depicted in Crunc...
Image via CrunchBase

A coworker sent this along. Β I’ve had this issue on a few contacts and didn’t really have time to delve into it.

Name removed to protect the innocent and good intentions. Β Be very careful with this and make sure you have a backup of all data that you plan to manipulate.


After serially using every calendar/address book interface under the sun and transitioning to Snow Leopard with Exchange syncing, I ended up with a bunch of munged Address Book extension labels in my iPhone Contacts like:


The extra long labels forces the text to be tiny, and rarely displays even then to say whether this is the work/home number.

If you encounter this problem and you’re a Mac user with a Unix background, I’m sure you can think of a dozen ways to fix this … else see some rudimentary Address Book/iTunes/command line steps below to handle large numbers of Contacts at once.

Caveat emptor.

The munged contacts had labels like:


… the bracketing parts are the problem. I can live with “HomePhone” versus “Home Phone”. YMMV.

Correcting this involves a few steps and a tiny bit of command line stuff:

– Attach your iPhone to your computer. Let it sync. Leave iTunes open.

– Open Address Book, select all your contacts, then File->Export to your Desktop, call it “backup.vcf” — don’t touch this file — if something goes wrong you’ll restore this.

– Do a second export of all the contacts to another file “munged.vcf”, or some name equally meaningful to you.

– Open a Terminal window, and cd to your Desktop (“cd ~/Desktop”). Just for paranoia’s sake, type “more *.vcf” and use the space bar to step through the files, making sure they contain all your contacts. Type “ls *.vcf” to confirm the files are the same size. Yeah — sheer paranoia, but who wants to reenter all their contacts? πŸ™

– In the previously opened Terminal window paste this command and press return:

cat munged.vcf | sed -e 's/EX-//' | sed -e 's/_$!<//' | sed -e 's/>!$_//' > fixed.vcf

– in the Terminal window type “more fixed.vcf” — confirm the ABLabel fields are corrected before going onto the next step. If the fixed.vcf file doesn’t look right, stop and consult a local Unix person. You did something wrong or your problem wasn’t the one I had. Bail out or get help.

– Go back to Address Book, select all the contacts (if not still selected), then Edit-> Delete Cards. Delete all your contacts. Paranoia now seems appropriate.

– Go back to the iTunes window. Select the iPhone in the Devices list on the left (if not selected), then select the Info tab at the top of the main window and scroll to the very bottom to the Advanced items, select Contacts under “Replace information on this iPhone:”. Click Apply and let the phone sync. Check the Contacts on the iPhone to see they are gone.

– Go back to the Address Book window and File->Import, selecting (you guessed it) “fixed.vcf” from your Desktop. Check the reloaded vcards/Contacts.

– Go back to the iTunes window, and again select the option to Replace the Contacts info, Apply, and let the iPhone sync.

– Try the Contacts on the iPhone, and the labels should be corrected. Delete all the ancillary files on your Desktop.

– Avoid whatever odd combination of things you did that caused the problem in the first place. πŸ˜‰

In case you want to mess with any other fields/changes, vcard format is described here:

Reblog this post [with Zemanta]

7 thoughts on “Fixing Mangled Contact Labels on iPhone”

  1. My good man, this blog entry saved my skin over the weekend… thanks for pushing me in the right direction!

    I’m an Apple consultant, and a client of mine had some jack’d up contact info that was being pushed into the cloud on Google Apps. A majority of his lables were riddled with the EX- etc tags, and also being labled as such that they weren’t compatible with label fields in both Google contacts, Addr Book on his Macs, his iPhone, and his (goddamn) Blackberry. Here’s the script I used to fix it all:

    cat original.vcf | sed -e ‘s/EX-//’ | sed -e ‘s/_$!!$_//’ | sed -e ‘s/BusinessPhone/Work/’ | sed -e ‘s/BusinessPhone2/Other/’ | sed -e ‘s/BusinessFax/Work Fax/’ | sed -e ‘s/BusinessFax2/Work Fax/’ | sed -e ‘s/MobilePhone/Mobile/’ | sed -e ‘s/MobilePhone2/Other/’ | sed -e ‘s/EmailAddress1/Work/’ | sed -e ‘s/EmailAddress2/Other/’ | sed -e ‘s/EmailAddress3/Other/’ | sed -e ‘s/EmailAddress4/Other/’ | sed -e ‘s/HomePhone/Home/’ | sed -e ‘s/HomePhone2/Other/’ | sed -e ‘s/HomeFax/Home Fax/’ | sed -e ‘s/HomeFax2/Home Fax/’ | sed -e ‘s/Custom Phone 1/Other/’ | sed -e ‘s/Work2/Other/’ | sed -e ‘s/Work Phone 2/Other/’ | sed -e ‘s/BusinessHomePage/Home/’ | sed -e ‘s/BusinessHomePage2/Other/’ | sed -e ‘s/Pager/Other/’ | sed -e ‘s/Pager2/Other/’ | sed -e ‘s/CompanyMainPhone/Other/’ | sed -e ‘s/CompanyMainPhone2/Other/’ > fixed.vcf

  2. I’ve just run into this problem myself. I have about 2000 contacts that originated in Exchange, but are now local “On My Computer.” In Apple Address Book the labels appear correct, but when I sync them to Google Contacts or export them as VCF or CSV for manual import to Google, the field labels are all mangled with the nonsense so when I use Google Sync to get them on the iPhone, none of the contact info appears in the right place or at all since the labels aren’t getting mapped properly.

    I tried the original fix from Vermyndax and it didn’t really help – although it did strip the brackets and clean up the labels a bit, it still doesn’t match to the Google Contacts labels, so it doesn’t fully solve the problem, since the labels still don’t match when synced to the iPhone, and it’s still a hot mess πŸ™‚

    So I tried joetekk’s solution since that appears to be specific to Google Contacts, which is ultimately where I need them to be correct since I really need them to sync between Address Book and Google and over the air via Google Sync to the iPhone. Unfotunately, when I run joetekk’s script, I get an error and I’m not Unix savvy enough to know how to fix it πŸ™ The error I get is

    sed: 1: “β€˜\n”: invalid command code ?

    If either of you are available to assist, I’m at the point of being willing to actually pay someone to to get this cleared up! I’m happy to contact one or both of you directly via email. Thanks!

  3. macsamurai, will you keep me posted if you find a fix? i have this same problem and cannot for the life of me find a solution.

  4. macsamurai: I had the same problem. The issue is with the “smart quotes” in the code above. Replace all occurences of:





  5. hmmmm. Still did not work for me.

    -bash: s/_??_//: No such file or directory
    -bash: s/BusinessPhone/Work/: No such file or directory
    -bash: s/BusinessPhone2/Other/: No such file or directory
    -bash: s/BusinessFax/Work: No such file or directory
    -bash: s/BusinessFax2/Work: No such file or directory
    -bash: s/MobilePhone/Mobile/: No such file or directory
    -bash: s/MobilePhone2/Other/: No such file or directory
    -bash: s/EmailAddress1/Work/: No such file or directory
    -bash: s/EmailAddress3/Other/: No such file or directory
    -bash: s/HomePhone/Home/: No such file or directory
    -bash: s/HomeFax/Home: No such file or directory
    -bash: s/HomeFax2/Home: No such file or directory
    -bash: s/Custom: No such file or directory
    -bash: s/Work2/Other/: No such file or directory
    -bash: s/Work: No such file or directory
    sed: option requires an argument — e

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.