Subject: Applescripting "process lines containing"
Posted: 2008-05-07 18:51:20
Author: Isaac Wingfield
First Message | Previous Message | Next Message | Last Message
I need an AppleScript that finds certain text "killthisline", and
then deletes the entire line containing that string.
I have tried a *lot* of combinations, but I cannot figure out the
syntax necessary to make AppleScript and TextWrangler do that.
The following compiles and runs, but does not kill the line:
--
tell application "TextWrangler"
activate
try
process lines containing string "killthisline" in text of document
of text window 1 output options {deleting matched lines:true}
end try
end tell--
If somebody could provide me with the proper syntax, I'd sure
appreciate it.
Isaac
--
For every problem, there is a solution that is simple, neat, and
wrong. — H. L. Mencken
Subject: Re: Applescripting "process lines containing"
Posted: 2008-05-07 20:08:55
Author: Tom Robinson
First Message | Previous Message | Next Message | Last Message
On 2008-05-08, at 10:51, Isaac Wingfield wrote:
> I need an AppleScript that finds certain text "killthisline", and
> then deletes the entire line containing that string.
>
> I have tried a *lot* of combinations, but I cannot figure out the
> syntax necessary to make AppleScript and TextWrangler do that.
The Record button in Script Editor is your friend. Removing a 'try'
so you can see errors is always helpful too.
tell application id "com.barebones.textwrangler"
process lines containing text 1 of text document 1 matching string
"killthisline" output options {deleting matched lines:true}
end tell
--
----------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/textwrangler_talk.shtml>
List archives: <http://www.listsearch.com/textwranglertalk.lasso>
To unsubscribe, send mail to: <textwrangler-talk-off@[Protected]>
Subject: Re: Applescripting "process lines containing"
Posted: 2008-05-08 19:29:58
Author: Isaac Wingfield
First Message | Previous Message | Next Message | Last Message
On May 8, 2008, at 2:03 AM, TextWrangler-Talk List wrote:
>
> From: Tom Robinson <barefootguru@[Protected]>
> Date: May 7, 2008 5:08:55 PM PDT
> Subject: Re: Applescripting "process lines containing"
>
>
> On 2008-05-08, at 10:51, Isaac Wingfield wrote:
>
>> I need an AppleScript that finds certain text "killthisline", and
>> then deletes the entire line containing that string.
>>
>> I have tried a *lot* of combinations, but I cannot figure out the
>> syntax necessary to make AppleScript and TextWrangler do that.
>
> The Record button in Script Editor is your friend. Removing a
> 'try' so you can see errors is always helpful too.
>
> tell application id "com.barebones.textwrangler"
> process lines containing text 1 of text document 1 matching string
> "killthisline" output options {deleting matched lines:true}
> end tell
I've written AppleScripts off and on (mostly off) ever since it came
out, but I still tend to forget that button.
Thanks.
isw