Hi Sonic,
As far as I know there is no way to call filters by name or to create
filters with AppleScript.
Nonetheless, you can record them and use them in your scripts.
1. In BBEdit, open the "Multi-File Search" window.
2. Configure the search options you want –– File and Folders filters
included.
3. Use a word that WILL NOT match for the Find: and Replace: fields. (This
is just a precaution to avoid accidentally replacing anything.)
find: ___THIS__WILL__N_E_V_E_R__BE__FOUND___
replace: ___THIS__WILL__N_E_V_E_R__BE__FOUND___
4. Launch Script Editor, open a new script and click the "Record a Script"
button.
5. Go back to BBEdit and click on "Replace All" in the "Multi-File Search"
window.
6. In Script Editor pause the recording.
7. Script Editor should have recorded the command.
tell application "BBEdit"
activate
replace "___THIS__WILL__N_E_V_E_R__BE__FOUND___" using
"___THIS__WILL__N_E_V_E_R__BE__FOUND___" saving no searching in {file
"macosx:Users:jj:Documents:Notebook:"} options {search mode:grep,
filter:{ID:"0DD90624-6CEA-4757-BCD1-A28CCA6DB640", filter_mode:or_mode,
filter_terms:{{operand:".applescript", field:«constant ****FnSf»,
operator:op_is_equal}}}, showing results:true} with skip shielded folders,
search invisible folders and search git_ignored files without text files
only
end tell
8. The Filter is in the options. You can use it in your AppleScript script.
filter:{ID:"0DD90624-6CEA-4757-BCD1-A28CCA6DB640", filter_mode:or_mode,
filter_terms:{{operand:".applescript", field:«constant ****FnSf»,
operator:op_is_equal}}}
An *easier option* is to create a Text Factory that includes your Filters
and call it from AppleScript like so.
tell application "BBEdit"
set vFactoryFile to POSIX file "/path/to/my/replace.textfactory"
apply text factory (vFactoryFile as alias) to (first text of first
document of first window) saving no
end tell
Note that, as your BBEdit copy is lagging behind a few versions, some of
this might not work as described.
HTH
Jean Jourdain
On Saturday, October 9, 2021 at 7:07:07 AM UTC+2 [email protected] wrote:
> I’m finding the documentation on using the *filter* option for *replace* in
> an AppleScript less than helpful: i don’t understand the syntax.
>
> Without that option, this *replace* command works perfectly in the
> overall script:
>
> *replace* (("TOCCHAP" & currchap *as* *text*) & ">") using navlinkholder
> searching
> in story_directory options {showing results:*false*} saving *yes*
>
>
> The moment i add the clause *filter* "Exclude index.html" so it becomes
> this:
>
> *replace* (("TOCCHAP" & currchap *as* *text*) & ">") using navlinkholder
> searching
> in story_directory options {showing results:*false*} *filter* "Exclude
> index.html" saving *yes*
>
> and try to run the script, it throws the following error:
>
> *error* "BBEdit got an error: Could not make some data into the desired
> type (MacOS Error code: -1700)" number -1700 to *record*
>
>
> There is an existing file filter i made via the multiple file Find
> interface named:
>
> Exclude index.html
>
> with settings:
>
> Any File name root is not index
>
>
> Seems obvious that my clause for *filter* is all wrong, but the
> documentation isn’t making it clear and searches on this group haven’t
> yielded anything.
>
>
> What is the proper syntax when one wants to use the BBEdit *filter* noun
> in AppleScript?
>
>
> Thanks in advance as always—the help has been stellar so far!
>
> (BBEdit 11.6.8, macOS 10.12.6, AppleScript 2.5, Script Editor 2.9, if any
> of these matter)
>
--
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 here. Follow @bbedit on Twitter: <https://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 view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/8e25f08e-abe1-471d-9a52-c1c54c22aa50n%40googlegroups.com.