• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: trying to change Address Book phone labels
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trying to change Address Book phone labels


  • Subject: Re: trying to change Address Book phone labels
  • From: "Ken G. Brown" <email@hidden>
  • Date: Thu, 22 Oct 2009 00:21:36 -0600

Title: Re: trying to change Address Book phone labels
Here's what I have finally that isn't efficient for sure but seemed to work:

tell application "Address Book"
activate
       
set thePeople to people
set numberOfPeople to count of people
  
repeat with peopleIndex from 1 to numberOfPeople
               
set thisPerson to properties of (item peopleIndex of thePeople)
       
set thisPersonPhones to properties of phones of (item peopleIndex of thePeople)
       
set thisName to name of thisPerson
             
set numPhones to count of thisPersonPhones
             
               
repeat with phoneIndex from 1 to numPhones
                     
set thisPhone to (item phoneIndex of thisPersonPhones)
                 
set thisLabel to the label of thisPhone
               
set newLabel to "unknown"
                      
                       
if (thisLabel is equal to "ph-home") or (thisLabel is equal to "home") or (thisLabel is equal to "phone-hm") then
                              
set newLabel to "ph-hm"
               
else if (thisLabel is equal to "phone-work") or (thisLabel is equal to "work") then
                            
set newLabel to "ph-wk"
               
else if (thisLabel is equal to "phone-mobile") or (thisLabel is equal to "mobile") then
                       
set newLabel to "ph-cell"
                      
end if
                 
if (newLabel is not equal to "unknown") then
                           
--                      display dialog "name = " & thisName & " - old label = " & thisLabel & ", new label = " & newLabel
                              
set the label of the (item phoneIndex of the phone) of (item peopleIndex of people) to newLabel
                       
save
                   
else
                           
--                      display dialog "name = " & thisName & " - no phone number found or label change not required"
                  
end if
         
end repeat
        end repeat
end tell
Main problem i think I was having before was that I was updating a local variable which wasn't getting back into the real Address Book Data
When I put 'save addressbook' in Script Debugger, it gets changed to just 'save' by itself.

Ken

At 5:27 PM -0600 10/21/09, Ken G. Brown apparently wrote:
Using latest Script Debugger in OS X 10.6.1.

I'm trying to change my Address Book contact phone labels to something shorter that will print completely.

So far I have this:

<snip>

Even though thisLabel picks up the correct values from Address Book and correctly enters the proper if conditions, and the label of thisPhone appears to get changed, nothing ever changes in Address Book. Next time I run the script, the contacts still have the old labels.

Can anyone shed light on why Address Book isn't getting the new labels?

Thx in advance for any tips.

Ken G. Brown

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >trying to change Address Book phone labels (From: "Ken G. Brown" <email@hidden>)

  • Prev by Date: Re: AS Bug
  • Next by Date: Re: AS Bug
  • Previous by thread: Re: trying to change Address Book phone labels
  • Next by thread: Re: trying to change Address Book phone labels
  • Index(es):
    • Date
    • Thread