Re: Naming a file
Re: Naming a file
- Subject: Re: Naming a file
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 18 Sep 2001 13:16:15 -0700
On 9/18/01 12:36 PM, "Bernard Azancot" <email@hidden> wrote:
>
One of my scripts is saving a special kind mail, from Outlook Express, as
>
text.
>
It works fine, but I would like to improve it a little.
>
>
The beginning of the mail text goes like this:
>
>
"0000000000
>
Last Name
>
First Name"
>
>
The original mail title goes like <xxx (number)>
>
>
My purpose is to save the mail as text, replacing the original file title
>
by:
>
>
<Last Name First Name (number)>
>
>
A little hint would be appreciated.
>
Thx in advance.
>
You haven't mentioned if there any blank lines above those "0000000" lines,
nor if (number) is really in parentheses, or if you're just doing that for
our benefit. It makes a difference. If they really are in parentheses in
the subject then:
tell application "Outlook Express"
set theMsg to item 1 of (get current messages)
set theSubject to subject of theMsg
set theContent to content of theMsg
end tell
set AppleScript's text item delimiters to {"("}
set theNumber to text item - 1 of theSubject
set AppleScript's text item delimiters to {")"}
set theNumber to text item 1 of theNumber
set AppleScript's text item delimiters to {""}
-- if there might be blank lines above "00000"
repeat with i from 1 to (count (paragraphs of theContent) )
set theLine to paragraph i of theContent
if theLine contains "00000" then
set newContent to text (paragraph (i + 1) of theContent) thru -1 of
theContent
exit repeat
end if
end repeat
(* -- or if "0000" is always line 1, just:
set newContent to text (paragraph 2 of theContent) thru -1 of theContent
*)
set newContent to "(" & theNumber & ")" & return & newContent
-------------------------------
If you don't really have parentheses around the number, then just
set theNumber to last word of theSubject
--
Paul Berkowitz
References: | |
| >Naming a file (From: Bernard Azancot <email@hidden>) |