Freakin' escaping DOS characters is nuts
Couldn't quite get that to work so here's a quick'n'dirty alternative:
RemVBSfHTM.cmd
RemVBSfHTM.exe
The command file walks the directory tree for .htm and .html files and passes them to the executable which writes out a new temp file up to the point it finds
<SCRIPT Language=VBScript> (case insensitive), it then writes out the remainder of the line, closes the file, renames the original file to
name-old+vbs, and then moves the temporary file into it's place.
Seems to work here OK but I can't try every possible combination of screwed up file.
Put both files in the same directory somewhere, open a CLI and run using: RemVBSfHTM.cmd <path>
Where <path> is the full path to the top level directory of the tree, quoted if it has spaces in the name, eg.
RemVBSfHTM.cmd "K:\html junk"Source of RemVBSfHTM.exe in AutoIt:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
$sTempFile = @TempDir & "\RemVBSfHTM.txt" $sTest = "<SCRIPT Language=VBScript>"
$sFile = $CmdLine[1]
_Exit()
_Exit()
_Exit()
It'll write out to RemVBSfHTM.log if it can't open either the original file for reading, the temporary file for writing, or renaming the original file (in which case it won't rename the temporary file).
So it might pay to make sure all files are not read-only and that you have permission to write to them before running.
Also, even if the HTML doesn't contain the relevant line it'll still get replaced, (I'm lazy).