• 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: Address book & Groups
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Address book & Groups


  • Subject: Re: Address book & Groups
  • From: Paul Berkowitz <email@hidden>
  • Date: Thu, 05 Apr 2007 12:28:37 -0700
  • Thread-topic: Address book & Groups

On 4/4/07 7:12 PM,
"applescript-users-bounces+berkowit=email@hidden"
<applescript-users-bounces+berkowit=email@hidden> wrote:

>
> tell application "Address Book"
> set the_peeps to (choose from list (get name of the people) with
> multiple selections allowed)
> set the_groups to (choose from list (get name of the groups))
> repeat with the_peep in the_peeps
> copy person the_peep to after the people of group (item 1 of
> the_groups)

Simpler:
    add person the_peep to group (item 1 of the_groups)

> end repeat
> save addressbook
> end tell
>
> I couldn't figure out a way to put them all in the group all at once,
> so had to use the repeat.

Actually, you haven't answered Bob's question, Michelle. He was asking : how
to add a particular person to several groups. You have shown him how to add
several people to one group.

Here's how to add one person to several groups:

tell application "Address Book"
    set the_peep to item 1 of (choose from list (get name of the people))
    set the_groups to (choose from list (get name of the groups) with
multiple selections allowed)
    repeat with the_group in the_groups
        add person the_peep to group the_group
    end repeat
    save addressbook
end tell


(It looks like there should be another way, too, since group is an element
of person as well as vice-versa. But that's actually a sort of 'read-only'
element - which is not something that AppleScript ever tells you or knows
about - since you can't make a new group at a person; you can only _get_
existing 'groups of person the_peep'.)




--
Paul Berkowitz


 _______________________________________________
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

  • Follow-Ups:
    • Re: Address book & Groups
      • From: Michelle Steiner <email@hidden>
References: 
 >Re: Address book & Groups (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: -Tunes - Overcoming File Permission Error -54
  • Next by Date: Re: Adding a leading zero
  • Previous by thread: Re: Address book & Groups
  • Next by thread: Re: Address book & Groups
  • Index(es):
    • Date
    • Thread