Re: trying to change Address Book phone labels
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 12:35:44 -0600
Just a couple more questions for someone more knowledgeable.
In this script I ended up looking at thepeople/thisPerson/phones which contained phone 1 and phone 2.
Phone 1 record is made up of id, label, and value. As I understand it, id is unique and persistent and stays with the record.
What would be a more direct way of writing the changed label back into the record containing that id?
What would have been my best way at the beginning for figuring out an overview of how the data is stored and retrieved by Address Book and how to access and change it? As it was I did a lot of trial and error, working from various examples I found online, none of which did exactly what I needed.
Any critiques of my script with suggestions for improvement would be appreciated.
Thx,
Ken G. Brown
At 9:54 AM -0700 10/22/09, email@hidden apparently wrote:
>Date: Thu, 22 Oct 2009 00:21:36 -0600
>From: "Ken G. Brown" <email@hidden>
>Subject: Re: trying to change Address Book phone labels
>To: email@hidden
>Message-ID: <p06240438c705a8cc748b@[10.0.1.33]>
>Content-Type: text/plain; charset="us-ascii"
>
>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
_______________________________________________
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