vbs版本:- Dim vbstr, fso, file
- Set fso = CreateObject("scripting.filesystemobject")
- Set ws = CreateObject("wscript.shell")
- For Each file In fso.GetFolder(ws.CurrentDirectory).Files
- If LCase(fso.GetExtensionName(file)) = "txt" Then
- vbstr = fso.OpenTextFile(file, 1).ReadAll()
- vbstr = Replace(vbstr, vbCrLf, "<br>")
- vbstr = "<html>" & vbCrLf & "<head>" & vbCrLf & "<title>" & file.Name & "</title>" & vbCrLf & "</head>" & vbCrLf & "<body>" & vbCrLf & vbstr & vbCrLf & "</body>" & vbCrLf & "</html>"
- fso.OpenTextFile(file, 2, 1).Write vbstr
- fso.MoveFile file, Replace(file.Name, ".txt", ".html")
- End If
- Next
- Set ws = Nothing
- Set fso = Nothing
复制代码
|