On 01/21/2019, at 10:08, Rich Siegel <[email protected] 
<mailto:[email protected]>> wrote:
> With a slight structural change to the script, you could use it in a "Run 
> AppleScript" step in a text factory. These can be applied to any combination 
> of files or folders. More on how to do this is in the user manual.


Hey Folks,

I don't normally think about Text Factories, because I personally find them 
awkward to work with compared to scripts (usually).

Nevertheless Rich's comment made me take a new look – since I hadn't for quite 
some time.

It was relatively trivial to turn the following shell script and AppleScript 
into two different Text Factories that operate on files in a specific folder 
path – thus saving a fair bit of scripting.


#!/usr/bin/env bash

sed '
    3d
    7d
    9d
'


on ApplyTextTransform(fileData)
    set fileData to paragraphs of fileData
    set item 3 of fileData to 0
    set item 7 of fileData to 0
    set item 9 of fileData to 0
    set fileData to text of fileData
    set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text 
item delimiters, linefeed}
    set fileData to fileData as text
    set AppleScript's text item delimiters to oldTIDS
    return fileData
end ApplyTextTransform

** This AppleScript is NOT designed for huge files, although it runs nearly 
instantaneously on a 5000 line file on my system.


•• NOTE ••

To run on disk items a Text Factory MUST be located in BBEdit's Scripts folder:

~/Library/Application Support/BBEdit/Scripts/

To run on the front text document (or the selected text in it) a Text Factory 
must be located in the Text Filters folder:

~/Library/Application Support/BBEdit/Text Filters/

Text Factories are not completely intuitive, so it's a good idea to review them 
in BBEdit's User Manual.

Creating and Configuring Text Factories p.132

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to