No way to "batch edit", exactly, but a script can select a group of contacts
by some criteria (or grab a set of contacts you've selected on screen) and
then cycle through them one by one making the same edit. Would that help?
For instance, I have a script that runs through all contacts and converts
all phone number fields to standard (aaa) nnn-nnnn format. You might be able
to modify it to make it do what you want:
-- DaveCort 4/12/04: added repeat loop to process every phone number
associated with the selected contact
-- DaveCort 4/12/04: added empty string check in reformat to improve perf
property phoneTypes : {"Home phone number", "Business phone number", "Mobile
phone number", "Home fax phone number", ¬
"Business fax phone number", "Pager phone number", "Assistant phone
number", "Other home phone number", "Other business phone number", ¬
"Custom phone number one", "Custom phone number two", "Custom phone
number three", "Custom phone number four"}
tell application "Microsoft Entourage"
activate
try
set theList to the selection
on error theErr number errNum
if errNum = -1728 then
-- Try formatting the text on the clipboard
set t to the clipboard
set t to my reformat(t)
set the clipboard to t
try
set the selection to t
on error
display dialog "Clipboard now contains: " & t
end try
return
else
display dialog "Error number:" & errNum & " " & theErr
return
end if
end try
repeat with theC in theList
if class of theC is not contact then
if class of theC is string then
-- Try formatting the text on the clipboard
set t to the clipboard
set t to my reformat(t)
set the clipboard to t
try
set the selection to t
on error
display dialog "Clipboard now contains: " & t
end try
return
end if
display dialog "No contacts are selected."
return
end if
set theID to (the ID of theC as string)
repeat with i in phoneTypes
set pn to run script "tell application \"Microsoft Entourage\"
to return " & i & " of contact ID " & theID
set newpn to (my reformat(pn)) as string
if newpn ‚ pn then run script "tell application \"Microsoft
Entourage\" to set " & i & " of contact ID " & theID & " to \"" & newpn &
"\""
end repeat
end repeat
end tell
on reformat(pNum)
if pNum = "" then return ""
set pNum to my onlyDigits(pNum)
set pNum to my formatNum(pNum)
return pNum
end reformat
on onlyDigits(s)
-- Strip all but digits from a string
set theDigits to "1234567890"
set newS to ""
repeat with i from 1 to length of s
set c to character i of s
if c is in theDigits then set newS to newS & c
end repeat
return newS
end onlyDigits
on formatNum(n)
-- Insert USA telephone formatting
--Choose one of two formats, comment out one unused
set mask to "(AAA) PPP-NNNN"
-- set mask to "AAA-PPP-NNNN"
if length of n is 10 then
set aaa to text 1 thru 3 of n
set ppp to text 4 thru 6 of n
set nnnn to text 7 thru 10 of n
set mask to my searchReplace(mask, "AAA", aaa)
set mask to my searchReplace(mask, "PPP", ppp)
set mask to my searchReplace(mask, "NNNN", nnnn)
set n to mask
else if length of n is 7 then
set n to text 1 thru 3 of n & "-" & text 4 thru 7 of n
end if
return n
end formatNum
-- routine to do a search and replace on text
on searchReplace(mainString, searchString, replaceString) -- Parameters:
search, replace, the String
set olddelis to AppleScript's text item delimiters
set AppleScript's text item delimiters to (searchString)
set theList to (every text item of mainString)
set AppleScript's text item delimiters to (replaceString)
set theString to theList as string
set AppleScript's text item delimiters to olddelis
return theString
end searchReplace