'Clean the HTML report generated by Compare suite

'On Error Resume Next

Set fso = CreateObject("Scripting.FileSystemObject")
myFile = ""

' Input via Arguments
If WScript.Arguments.Count > 0 then
	If fso.FileExists(WScript.Arguments.Item(0)) Then
		myFile = WScript.Arguments.Item(0)
	End If
End If

'Input via Explorer
If myFile = "" Then 
	Set ObjFSO = CreateObject("UserAccounts.CommonDialog")
	ObjFSO.Filter = "HTML File|*.html"
	ObjFSO.FilterIndex = 3
	ObjFSO.ShowOpen
	myTxtFile = ObjFSO.FileName
End If

'Call the Convert Procedure
If myFile <> "" Then
	Call DoConvert(myFile)
End If 	

Sub DoConvert(dFile)
	Set inFile  = fso.OpenTextFile(dFile, 1)
	Set ObjFile = fso.GetFile(dFile)
	Set outFile = fso.CreateTextFile(ObjFile.ParentFolder  & "\Small " & ObjFile.Name, True)
	Set ObjFile = Nothing
	
	'Loop file & copy info to new file
	Do until inFile.AtEndOfStream
		dLine = inFile.ReadLine
		'Replace the Deleted Color		
		If InStr(dLine,"#FFAEAE") <> 0 Then
				dLine = Replace(dLine, "#FFAEAE","#FF0000" )
		End If
		'Do NOT output the Groups of interest section
		If InStr(dLine,"<h2>Groups of interest</h2>") <> 0 Then
			For I = 1 to 5
				dLine = inFile.ReadLine
			Next
		End If
		'Do NOT output the Comparison options section
		If InStr(dLine,"<h2>Comparison options</h2>") <> 0 Then
			For I = 1 to 23
				dLine = inFile.ReadLine
			Next
		End If
		'Do NOT output the files that did not change
		If InStr(dLine,"<td class=" & chr(34) &"line" & chr(34) & ">") = 0 Then
			outFile.WriteLine(dLine)
		End If
	Loop
	outFile.Close
	inFile.Close
End Sub

