I had some issues with a damaged database yesterday and tried to
rebuild. Everything seems fine now, I think, but I did get a message
saying some data may have been lost. Just now I found that one of the
categories I use the most has disappeared, the one that I use to pull
up all of our members who get our newsletter electronically. After I
picked my jaw up from the floor, I realized I still have a recently-
created group of these contacts, but the "newsletter" category is
missing from each one individually. Is there any automated way to
reassign "Newsletter" category to them without going through 700
contacts and doing it by hand?
Why oh why did have to choose THAT one to vaporize?
there wasn't, but there is now
this script will assign the category you choose to the members of a
group you select.
for a one-off use, you can just paste it into the window of Apple's
Script Editor and press the 'Run' button. Save it if you think oyu may
need it again.
oh, and watch out for line-wraps - some of the long lines will probably
break in the forum message and will need to be re-joined before the
scrpt will compile correctly.
post back here if you are having trouble.
-- Set Category of Group Members v1.0 (2008-10-11)
-- an applescript by Barry Wainwright <mailto:
[email protected]>
-- Adds a user-selected category to the members of the selected group
-- This script released under a Creative Commons Attribution,
NonCommercial, ShareAlike 2.0 England & Wales License.
-- see <
http://creativecommons.org/licenses/by-nc-sa/2.0/uk/> for full
details
tell application "Microsoft Entourage"
-- select or create a category
set chosenCategoryName to choose from list (get name of categories)
with title "Category Selection" with prompt "Select a category to be
applied to Group Members..." OK button name "Select" cancel button name
"New..." without multiple selections allowed and empty selection allowed
try
set chosenCategory to category (item 1 of chosenCategoryName)
on error
-- user pressed "New"
set catCreated to false
repeat until catCreated
set creationResult to display dialog "Name for new category..."
default answer "Enter Category Name" buttons {"Abort", "Create"} default
button 2 with title "Category Creation"
if button returned of creationResult is "Abort" then
-- user pressed abort
return
else
set catName to text returned of creationResult
try
set chosenCategory to (make new category with properties
{name:catName})
set catCreated to true
on error
-- couldn't make category
set repeatResult to button returned of (display dialog "I Couldn't
create a category of that name (one may already exist)." buttons
{"Abort", "Try Again..."} default button 2)
if repeatResult is "Abort" then return
end try
end if
end repeat
return
end try
-- Select the Group
if class of default mail account is Exchange account then
set addressBook to last address book
else
set addressBook to address book 1
end if
set theGroups to name of every group of addressBook
set groupName to first item of (choose from list theGroups with title
"Group Selection" with prompt "Select a group to operate on..." OK
button name "Select" cancel button name "Abort" without multiple
selections allowed and empty selection allowed)
set theGroup to group groupName
-- process the contacts of this group
repeat with thisGroupEntry in every group entry of theGroup
set entryAddress to address of content of thisGroupEntry
set foundContacts to find entryAddress
repeat with aContact in foundContacts
set contactCats to category of aContact
if {chosenCategory} is not in contactCats then set category of
aContact to (contactCats & {chosenCategory})
end repeat
end repeat
end tell