把txt文件托放到這個vbs上試一下,它會自動生成一個htm文件。需要修的地方說一下。
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格式,并且有換行效果。