Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Some custom fields of contact cards in Contacts.app are really annoying. For example, nicknames always appear in Mail.app. To make things worse, there seems to be no menu option to delete custom fields from cards once created.

Is there any way to delete custom fileds from cards? For example, with an AppleScript? I tried to write one but failed.

The OS X version of my Mac is 10.8.2.

share|improve this question
    
Oh, another thing is prefixes. I used to add Mr., Ms., Dr., Prof. etc. to distinguish but they turned out to be really superfluous and silly. –  ksh Jan 10 '13 at 3:27

1 Answer 1

up vote 0 down vote accepted

I was able to delete the nickname field of a contact simply by emptying it. However, here's an AppleScript that will allow you to select nicknames to remove.

tell application "Contacts" 
  -- Get a list of people who have nicknames
  set ListOfNicknames to people whose nickname is not missing value

  repeat with x in ListOfNicknames
    -- For each person, ask if their nickname should be removed
    set dialogResult to display dialog ¬
      "Remove nickname \"" & x's nickname & "\" from " & x's name & "?" ¬
      with icon caution ¬
      buttons {"No", "Yes"} ¬
      default button "No"

    if button returned of dialogResult is "Yes" then
      set nickname of x to missing value
      save
    end if    
  end repeat
end tell

You should be able to easily modify this if you want to delete all nicknames, or handle a different field like the prefix (known to AppleScript as the title).

Thanks:
Mac OS X Tips, for showing me the save command that I was missing;
The AppleScript Documentation, for existing;
And @KevinSayHi, for giving me a chance to brush up on my AppleScript.

share|improve this answer
1  
I don't know which version of OS X you are running (I suppose it should be 10.8, since Contacts is only introduced to replace Address Book in 10.8), but the code won't compile on my AppleScript Editor. field is not a class. Error message: "The variable field is not defined." Actually I checked the library for Contacts.app, and there is no entry named field. –  ksh Jan 10 '13 at 7:24
    
Also, Contacts never allowed me to empty the nickname field once created. The best thing I can do is to enter a blank character, and the contact would show up in Mail as something like Tyler Wayne " " twayne@askdifferent.com. I'm running 10.8.2, but I believe the same thing occured in 10.8.0 and 10.8.1. I've tried many times. –  ksh Jan 10 '13 at 7:29
    
Oh, sorry, I didn't read your code carefully last time. When I did that I got what you mean. It works. Thank you very much! Cool script. –  ksh Jan 10 '13 at 9:13
    
Furthermore, last time I did something similar but failed. Turned out that I tried to delete the fields, rather than setting them to missing value. I should have read the library more carefully :( –  ksh Jan 10 '13 at 9:16
    
Actually, you were right. field was my attempt at making it easier to handle more than just nickname. It was a mistake on my part; I've edited the code to be correct now. Thank you. –  Tyler Wayne Jan 10 '13 at 16:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.