I don't think you want to be opening each document and doing your find-replace actions.
-------------------------------------------------------------------------------------------
# Find/Replace in all text files in a directory WITH recursion.
-------------------------------------------------------------------------------------------
set searchFolder to "/test_directory/BBEdit_Text_File_Test/"
tell application "BBEdit"
replace "John \\w+" using "•••••" searching in searchFolder options {
search mode:
grep,
case sensitive:
false}
with text files only and saving # without recursion replace "now.+?time" using "*****" searching in searchFolder options {search mode:grep, case sensitive:false} with text files only and saving # without recursion
end tell
-------------------------------------------------------------------------------------------
# Find/Replace in specific files using posix paths WITH recursion.
-------------------------------------------------------------------------------------------
set fileList to {"~/test_directory/BBEdit_Text_File_Test/test_folder_01/bbedit_test_file_005.txt", "~/test_directory/BBEdit_Text_File_Test/test_folder_01/bbedit_test_file_006.txt", "~/test_directory/BBEdit_Text_File_Test/test_folder_01/bbedit_test_file_007.txt"}
set homeFolderPosix to POSIX path of (path to home folder)
# This loop only necessary if using home-path notation.
repeat with i in fileList
if contents of i starts with "~/" then
set contents of i to homeFolderPosix & text 3 thru -1 of (contents of i)
end if
end repeat
tell application "BBEdit"
replace "carpenter" using "•••••" searching in fileList options {search mode:grep, case sensitive:false} with text files only and saving # without recursion
replace "untitled" using "*****" searching in fileList options {search mode:grep, case sensitive:false} with text files only and saving # without recursion
end tell
-------------------------------------------------------------------------------------------
# Find/Replace in selected files in the Finder WITH recursion.
-------------------------------------------------------------------------------------------
tell application "Finder" to set fileList to selection as alias list
if fileList ≠ {} then
tell application "BBEdit"
replace "good" using "•••••" searching in fileList options {search mode:grep, case sensitive:false} with text files only and saving # without recursion
replace "men" using "*****" searching in fileList options {search mode:grep, case sensitive:false} with text files only and saving # without recursion
end tell
end if
-------------------------------------------------------------------------------------------
If you'll give me a better idea of the file structure you're working with, I'll give you a more specific script.
--
Best Regards,
Chris