Hello Paul,
Got the script working with a couple of additions as follows.
" on run
tell application "Microsoft Entourage" --
repeat with theMsg in (get current messages)
set theSubject to subject of theMsg
if theSubject starts with "Re:" or theSubject starts with " Re:"
then
try
if theSubject starts with "Re:" then
set theSubject to text 4 thru -1 of theSubject
else if theSubject starts with " Re:" then
set theSubject to text 5 thru -1 of theSubject
end if
repeat while theSubject starts with " "
set theSubject to text 2 thru -1 of theSubject
end repeat
on error -- <no subject>
set theSubject to ""
end try
set subject of theMsg to theSubject
end if
end repeat
end tell
end run"
A subject I would like to fix sometimes follows this pattern "[Fwd: Re SHAY
too slow]"
Any clues on a script to make this into "Re SHAY too slow"
I have a script to remove [ ], what would one to remove (some text) look
like.
The one to Remove [ ] from Subject is as follows.
" on run
tell application "Microsoft Entourage" --
set currentMessages to the current messages --
repeat with theMsg in the currentMessages --
set str to the subject of theMsg
set x to str -- Save for comparison
if str contains "]" then
-- Search for something like "Re: [xxxx]" at the start of
the subject, and strip it
if str begins with "[" or str begins with "re:[" or str
begins with "re: [" then
-- Remove "re:"
set re to str begins with "re:"
if re then
set str to text 4 thru -1 of str
end if
--Now remove the bracketed prefix
set sd to AppleScript's text item delimiters
set AppleScript's text item delimiters to "]"
try
set temp to text items 2 thru -1 of str
set str to temp as text
on error
set str to "<No Subject>"
end try
set AppleScript's text item delimiters to sd
if re then
set str to "Re:" & str
end if
--Remove possible leading blank(s)
repeat while (character 1 of str is " ")
try
set str to text 2 thru -1 of str
on error
set str to "<No Subject>"
end try
end repeat
end if
-- If found, replace subject, otherwise leave subject alone
if str is not equal to x then
set subject of theMsg to str
end if
end if
end repeat --
end tell --
end run"
Geoff WALLACE
On 1/11/04 6:59 PM, "Paul Berkowitz" <[EMAIL PROTECTED]> wrote:
> On 10/31/04 11:25 PM, "Mike Dano" <[EMAIL PROTECTED]> wrote:
>
>> I tried to go in and modify some existing AppleScripts but they were a
>> little to complex for me to figure out. Is there a simple way to replace any
>> instance of "Re:", "Re: ", " Re:" or " Re: " in a subject with nothing ("")?
>
> Frankly, I've never ever seen a subject start with " Re:" but I'll take your
> word for it.
>
>
> repeat with theMsg in (get current messages)
> set theSubject to subject of theMsg
> if theSubject starts with "Re:" or theSubject starts with " Re:" then
> try
> if theSubject starts with "Re:" then
> set theSubject to text 4 thru -1 of theSubject
> else if theSubject starts with " Re:" then
> set theSubject to text 5 thru -1 of theSubject
> end if
> repeat while theSubject starts with " "
> set theSubject to text 2 thru -1 of theSubject
> end repeat
> on error -- <no subject>
> set theSubject to ""
> end try
>
> set subject of theMsg to theSubject
>
> end if
> end repeat
>
--
To unsubscribe:
<mailto:[EMAIL PROTECTED]>
archives:
<http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
old-archive:
<http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>