Results 1 to 3 of 3
  1. #1

    Member Since
    Jan 25, 2012
    Applescript and Address Book
    Hello, I have a question about how to use AppleScript to make bulk modifications to my Address Book. I am trying to find all phone numbers that are labeled as the person's "main" phone number, and change it to "other". This is because my phone does not sync entries under "main".

    After googling a bunch of sites, I came up with the following code:
    tell application "Address Book"
    	set thePeople to every person whose first name = "Andy"
    	repeat with thePerson in thePeople
    		set thePhones to phones of thePerson
    		repeat with thePhone in thePhones
    			set theLabel to (label of thePhone)
    			set theLastName to last name of thePerson
    			display dialog theLastName & " " & theLabel
    			if theLabel = "main" then
    				set (label of thePhone) to "other"
    			end if
    		end repeat
    	end repeat
    end tell
    When I run the script, it gives me three dialogs: "Jackson work", "Hu main", and "Long main". I run it a second time, and it says: "Jackson work", "Hu other", "Long other". It looks like it's worked!

    However, if I look at the entries in Address Book, they have not changed. Furthermore, if I quit and reopen Address Book and run the script again, it goes back to saying "main" the first time and then "other" all subsequent times.

    Anyone know what's up?

  2. #2

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    West Sussex, UK
    The code you have in the above script, does not change anything in the Address Book, but simply displays Dialog Boxes with the results.

    You will have to change the script to change the settings in the Address Book app itself.

    Although I do a lot of scripting, I have not scripted tje Address Book before, but you can
    get a lot of expert help with Applescript at this Forum site.


    Regards Mark

  3. #3

    Member Since
    Jan 25, 2012
    Thanks for the tip! I posted my question on MacScripter and someone gave me the solution! Here's a link to the post: MacScripter / Applescript and Address Book

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Conecting to LDAP AD address book from Address Book
    By Wheeljack in forum macOS - Operating System
    Replies: 1
    Last Post: 12-12-2009, 09:29 PM
  2. Address book failure + Printing the address book details
    By ideliver in forum macOS - Operating System
    Replies: 0
    Last Post: 01-09-2009, 02:51 AM
  3. Replies: 0
    Last Post: 01-08-2009, 06:30 AM
  4. Replies: 0
    Last Post: 01-01-2008, 08:06 PM
  5. Urgent help...Synchronizing my phone/PDA address to the macbook address book!!!
    By Digitalsoul in forum Other Hardware and Peripherals
    Replies: 4
    Last Post: 08-14-2007, 10:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts