用VBS将一篇txt后缀的内容保存为html格式

do.vbs
复制代码 代码如下:

'BY Coo_boi
If WScript.Arguments.Count=0 Then WScript.Quit
Dim fso,txt,htm
txt=WScript.Arguments(0)
Set fso=CreateObject("Scripting.FileSystemObject")
Set htm=fso.CreateTextFile(txt&".htm",True)
title=fso.GetFile(txt).Name
title=Left(title,Len(title)-4)
MsgBox title
htm.WriteLine ""
htm.WriteLine ""
htm.WriteLine ""&title&""
htm.WriteLine ""
htm.WriteLine ""
htm.WriteLine "

"&title&"

"
htm.WriteLine "
"
For Each line In Split(fso.OpenTextFile(txt).ReadAll ,vbCrLf)
htm.WriteLine line&"
"
Next
htm.WriteLine ""
htm.WriteLine ""
htm.Close
WScript.Echo "将txt转换为html成功"

将上面的代码保存为do.vbs,然后将1.txt托动到do.vbs上。即可将txt的内容生成为html格式,并且有换行效果。

你可能感兴趣的:(用VBS将一篇txt后缀的内容保存为html格式)