Re: Scripting text edit
Re: Scripting text edit
- Subject: Re: Scripting text edit
- From: has <email@hidden>
- Date: Fri, 10 Jun 2005 22:14:10 +0100
Andrew wrote:
>I have a simple script that is intended to take an RTF file (exported from Mail) and strip put all the "quoted" replies.
>
>When exporting from mail it seems any threaded replies are given a different color. Thus on its face it seems a simple applescript loop to look at each paragraph and delete it if the color is not black is the perfect solution.
Actually the perfect solution would be:
tell application "TextEdit"
delete (every paragraph where its color is not {0, 0, 0}) of document 1
end tell
Whether or not this will always work is another question. I see that in TextEdit 1.2 the above filter clause doesn't notice text that's black by default and deletes those paragraphs as well as the coloured ones. (Stupid TextEdit. BTW, if your copy has the same problem, feel free to file a bug on it.) If that's an issue for you, the safe solution would be to iterate over each paragraph and perform the test in AppleScript (note that this deletes from the end of the document; yours started at the wrong end which will cause problems):
tell application "TextEdit"
tell text of document 1
repeat with i from (count paragraphs) to 1 by -1
if color of paragraph i is not {0, 0, 0} then delete paragraph i
end repeat
end tell
end tell
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden