LineBreaks
filter fix {lf|cr}
Fixes problems with line endings.
Lines are broken at the line feed character. If preceded by a carriage return both are removed. However a single carriage return without a line feed does not break the line.
cr - removes all stray CR and LF left on each line.
lf - add a LF to any CR embeded in the middle of the line.
It then writes the line with a CRLF at the end (the writeline method adds it).
Example
Fixes win.ini, not that it needs fixing, and sends it to the screen
filter fix cr <"%systemroot%\win.ini"
You'll have to modify script as it expects command line arguments.
Set Arg = WScript.Arguments
set WshShell = createObject("Wscript.Shell")
Set Inp = WScript.Stdin
Set Outp = Wscript.Stdout
If Arg(1) = "cr" then
Do Until Inp.AtEndOfStream
Line=Inp.readline
Line=Replace(Line, vbcr, "")
Line=Replace(Line, vblf, "")
outp.writeline Line
Loop
End If
If Arg(1) = "lf" then
Do Until Inp.AtEndOfStream
Line=Inp.readline
Line=Replace(Line, vbcr, vbcrlf)
outp.writeline Line
Loop
End If
To use you need to run with cscript.
cscript //nologo c:\scriptname.vbs fix cr <inputfile.txt >outputfile.txt
I'm sure you can modify it. Regular Expressions are overkill for this.