华域联盟 vbs 用VBS将一篇txt后缀的内容保存为html格式

用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 "<html>"

htm.WriteLine "<head>"

htm.WriteLine "<title>"&title&"</title>"

htm.WriteLine "</head>"

htm.WriteLine "<body>"

htm.WriteLine "<h1 align=center>"&title&"</h1>"

htm.WriteLine "<hr color=red>"

For Each line In Split(fso.OpenTextFile(txt).ReadAll ,vbCrLf)

htm.WriteLine line&"<br>"

Next

htm.WriteLine "</body>"

htm.WriteLine "</html>"

htm.Close

WScript.Echo "将txt转换为html成功"

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

本文由 华域联盟 原创撰写:华域联盟 » 用VBS将一篇txt后缀的内容保存为html格式

转载请保留出处和原文链接:https://www.cnhackhy.com/16011.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部