0

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.

1
  • 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. – 4ae1e1 Jan 10 '13 at 3:27
0

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.

5
  • 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. – 4ae1e1 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. – 4ae1e1 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. – 4ae1e1 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 :( – 4ae1e1 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 Mumford Jan 10 '13 at 16:13
0

This short AppleScript deletes all Outlook fields from all contacts. Optionally, it can also delete all notes.

tell application "Contacts"
    delete (every url of every person whose value contains "outlook")
    -- set note of every person to missing value
    save
end tell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .