I have written a script that calls BBedit to do a find a replace across multiple files. I got the BBedit Applescript code from recording within the program itself. I did a manual search and replace for example code, but I want to replace the search string and replace with string with variable values within applescript. Seems pretty straightforward.
Here is a code snippet:
(tell application “BBEdit 6.5”
activate
replace “CBB91F15-10D9-4A91-9C6D-84F29E93F44F” using “entry1” saving yes searching in alias “Macintosh HD:Users:old_bfindlay:Sites:” options {search mode:grep, case sensitive:true, match words:false, extend selection:false, showing results:true}
end tell)
tell application “BBEdit 6.5”
activate
display dialog (current_name)
replace current_name using new_item_name saving yes searching in alias “Macintosh HD:Users:old_bfindlay:Sites:” options {search mode:grep, case sensitive:true, match words:false, extend selection:false, showing results:true}
the commented out bit is the recorded from BBEDIT code (it works when I uncomment it) and the other is the same code with current_name and new_item_name taking the place of the strings CBB91F15-10D9-4A91-9C6D-84F29E93F44F and entry1. When I run this - it fails. BBedit activates, runs through the files, but fails to find or replace anything. I have done a few error checking procedures:
A: I did a comparison in Applescript with :
if current_name = “CBB91F15-10D9-4A91-9C6D-84F29E93F44F” then
beep 5
display dialog (“They match!”)
end if
just before passing current_name to the BBedit tell statement. (The dialogue pops up - indicating that current_name contains the proper string value)
B: I tried parsing " symbols before and after the string value of current_name - again no luck.
Yet if I replace just the current_name in the BBedit code with its string value - the search works!! How do I get this bit of BBEdit code to accept variable input??
AAAARRRGGHHHH- two hours of troubleshooting on this, and my eyes are spirals! To me, this code snippet looks just fine!!! What is the problem??