Hi, Chris!

Thank you so much for the script; I have been testing it out with various 
configurations, and it’s working great!

You have shown me that after many years, I still have a lot to learn about 
the endless enigma known as “AppleScript.”

;-)

Blessings, and thank you!

On Tuesday, December 7, 2021 at 9:20:41 PM UTC-7 [email protected] wrote:

> On Dec 07, 2021, at 20:44, Richard Fairbanks <[email protected]> wrote:
>
> I want BBEdit to return the number of times a text string appears in the 
> files in a directory. The following works to replace any such text:
>
> ------------------------------
>
> Hey Richard,
>
> The simple way is to do a straight file search:
>
>
> If you want to script it then you need to do something like this:
>
> --------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2021/12/07 22:17
> # dMod: 2021/12/07 22:17 
> # Appl: BBEdit
> # Task: Count the Number of Files Containing a Search String 
> – Recursive-File-Search
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Script, @ASObjC, @BBEdit, @Count, @Files, 
> @Containing, @Search, @String, @Recursive, @Search
> --------------------------------------------------------
> *use* AppleScript version "2.4" --» Yosemite or later
> *use* *framework* "Foundation"
> *use* *scripting additions*
> --------------------------------------------------------
>
> *set* searchDir *to* "~/test_directory/Many_Files_6000/"
>
> *set* searchDir *to* ((*current application's* NSString's 
> stringWithString:searchDir)'s ¬
>     stringByExpandingTildeInPath) *as* *text*
>
> *tell* *application* "BBEdit"
>     *set* foundRecord *to* *find* "three\\nfour" searching in searchDir 
> options {search mode:*grep*, case sensitive:*false*, starting at top:
> *true*, returning results:*true*}
>
>     
>     *if* found *of* foundRecord *then*
>         *return* length *of* found matches *of* foundRecord
>     *end* *if*
>
>     
> *end* *tell*
>
> --------------------------------------------------------
>
>
> --
> 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 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/78f86edc-ea5b-4d84-930f-205be0742ce1n%40googlegroups.com.

Reply via email to