--------------------------------------------------------
# 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
--------------------------------------------------------