I have a batch file running which spits out a text/html file. The batch file is causing some line breaks in the text file, which do not translate very well in opening the file in an email. I have been trying to read up on CScript to create a vbs script that can read the text file and strip out the line breaks but have had no luck. Any advice?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Not sure how you'd prefer to do it, but this script takes a filename as an argument and writes the results to the same file.
Const ForReading = 1, ForWriting = 2
Dim fs, txt, contents
Set fs = CreateObject("Scripting.FileSystemObject")
Set txt = fs.OpenTextFile(WScript.Arguments(0), ForReading)
contents = txt.ReadAll
txt.Close
contents = Replace(contents, vbCr, "")
contents = Replace(contents, vbLf, "")
Set txt = fs.OpenTextFile(WScript.Arguments(0), ForWriting)
txt.Write contents
txt.Close