On 09/09/2018, at 01:02, Andrew Brown <[email protected] <mailto:[email protected]>> 
wrote:
> My BBEdit scripts went down with some earlier computer and I am looking for a 
> search-and-replace for grep and non-grep on multiple folders or files.


Hey Andrew,

That covers a lot of ground.

Disparate files and folders?

Files and folders in the same tree?

Here's one example:

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2014/10/29 07:10
# dMod: 2018/09/09 14:04
# Appl: BBEdit
# Task: Find and Replace in Files On-Disk.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Find, @Replace, @Files, @Disk
----------------------------------------------------------------
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
----------------------------------------------------------------

# The Search Folder reference can be either an alias or a posix path or a posix 
file.

set searchFolderPath to "~/test_directory/Find_and_Replace_It_Test/"

if searchFolderPath starts with "~" then
    set searchFolderPath to ((current application's NSString's 
stringWithString:searchFolderPath)'s stringByExpandingTildeInPath) as text
end if

----------------------------------------------------------------

set findStr to "good men"
set replStr to "I want my MTV!"

----------------------------------------------------------------
tell application "BBEdit"
    replace findStr using replStr searching in searchFolderPath ¬
        options {search mode:grep, case sensitive:false, showing results:false} 
¬
        saving true ¬
        recursion true ¬
        with text files only
end tell
----------------------------------------------------------------

> I also need to convert HTML to text in batch mode, with the options that 
> BBEdit offers for single file conversions.

If you want to do this in batch mode then a Text Factory is probably the way to 
go.

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