当前位置: 移动技术网 > IT编程>脚本编程>VBScript > 用VBS将一篇txt后缀的内容保存为html格式

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

2017年12月08日  | 移动技术网IT编程  | 我要评论
do.vbs复制代码 代码如下:'by coo_boi if wscript.arguments.count=0 then wscript.quit dim fso,txt
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格式,并且有换行效果。

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网