My Old Script is Bricked!

Oh, god.

I painstakingly recorded a long series of text replacements to polish an export dump into a decently slick html document. I haven’t used it in a while, and now it’s doing nothing, so something’s changed in BBEdit and/or in Sequia. Can anyone spot an obvious problem?

tell application "BBEdit"
	activate
	replace "<a href=\"javascript:share\\(\\d+?\\);\"><img src=\"sharing/addlibrary.png\" title=\"Add to my Library\"></a></b></p>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	
	replace "<a href=\"javascript:share\\(\\d.+?\\);\"><img src=\"sharing/addlibrary.png\" title=\"Add to my Library\"></a></b></p>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	replace "<span class=\"style1\"><b>Director:</b>" using "<BR><span class=\"style1\"><b>Director:</b>" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	replace "<b><a href=\"" using "<a href=\"" searching in text 1 of text document 1 options {starting at top:true}
	replace "()" using "" searching in text 1 of text document 1 options {starting at top:true}
	replace "Special Features" using "<BR><BR>Special Features" searching in text 1 of text document 1 options {starting at top:true}
	replace "            <b>(.+?):</b>\\n            \\n            <br>\\n" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	replace " <b>(.+?):</b>\\n            \\n            <b>" using "<B>" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	replace "&nbsp;" using "" searching in text 1 of text document 1 options {starting at top:true}
	replace " <b>(.+?):</b>\\n            \\n            <b>" using "<B>" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	
	replace "<b>(.+?):</b>\\n            \\n            <br>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	replace "<b>(.+?):</b>\\n             \\n            <br>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	replace "<b>(.+?):</b>\\n             \\n            \\n            <br>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	
	replace "nk\">\\n              (.+?) \\n              </a>\\n            <BR><span" using "nk\">\\n              \\1 \\n              </a>\\n            <BR><BR><span" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
	save text document 1
end tell

Can you put up a sample document that BBEdit would actually find your strings in?

Here is a document that previously worked with this script, but no longer does, hence my query.

I don’t have a dropbox account, thus I can’t get your file.
Post the file directly in this forum.

You don’t need a DropBox account to see the file. And the file upload feature will not attach my HTML file.

I can view it yer, but every browser I’ve tried only lets me view it. Cant download it or select the text to copy/paste it.

Here is my sample file to show I can upload
Sample HTML File.html.zip (828 Bytes)

I compressed mine in a zip file

How could I have failed to realize I needed to zip it.

See attached.
sample doc.html.zip (304.3 KB)

It works for me.

The only line that is replacing anything is

replace "Special Features" using "<BR><BR>Special Features" searching in text 1 of text document 1 options {starting at top:true}

also, near the end of each line you have

searching in text 1 of text document 1

There is no need to put a number after ‘text’
like so…

searching in text of text document 1

Here is the modified one…

tell application "BBEdit"
	replace "<a href=\"javascript:share\\(\\d+?\\);\"><img src=\"sharing/addlibrary.png\" title=\"Add to my Library\"></a></b></p>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
	replace "<a href=\"javascript:share\\(\\d.+?\\);\"><img src=\"sharing/addlibrary.png\" title=\"Add to my Library\"></a></b></p>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
	replace "<span class=\"style1\"><b>Director:</b>" using "<BR><span class=\"style1\"><b>Director:</b>" searching in text of text document 1 options {search mode:grep, starting at top:true}
	replace "<b><a href=\"" using "<a href=\"" searching in text of text document 1 options {starting at top:true}
	replace "()" using "" searching in text of text document 1 options {starting at top:true}
	replace "Special Features" using "<BR><BR>Special Features" searching in text of text document 1 options {starting at top:true}
	replace "            <b>(.+?):</b>\\n            \\n            <br>\\n" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
	replace " <b>(.+?):</b>\\n            \\n            <b>" using "<B>" searching in text of text document 1 options {search mode:grep, starting at top:true}
	replace "&nbsp;" using "" searching in text of text document 1 options {starting at top:true}
	replace " <b>(.+?):</b>\\n            \\n            <b>" using "<B>" searching in text of text document 1 options {search mode:grep, starting at top:true}
	replace "<b>(.+?):</b>\\n            \\n            <br>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
	replace "<b>(.+?):</b>\\n             \\n            <br>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
	replace "<b>(.+?):</b>\\n             \\n            \\n            <br>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
	replace "nk\">\\n              (.+?) \\n              </a>\\n            <BR><span" using "nk\">\\n              \\1 \\n              </a>\\n            <BR><BR><span" searching in text of text document 1 options {search mode:grep, starting at top:true}
	save text document 1
end tell
1 Like

Are you sure the document itself is the same? I searched for some of the terms and didn’t find any thing.

There’s no “Add to my Library” in the doc. Has that been changed to add to a database?

Yeah, it’s weird. It’s an export from an app I have not upgraded in years, so it should be exporting per usual. I’d figured that Sequoia had broken some of my code, but, yeah, going through the doc, it’s…not that!

The good part is that while I remember this AppleScript doing a ton of work, it’s not really so extensive, and I just did a manual clean-up of the doc on my own. No biggie.

So to quote Iris DeMent, I’ll just “Let The Mystery Be”

Thanks to you both for looking at it.