文章摘要
该脚本代码实现了从HTML文件中提取内容并替换特定内容的自动化处理流程。主要步骤包括:
1. 使用`WshShell.Run`启动cmd脚本,列出所有HTML文件并保存到`list.htm`。
2. 读取`list.htm`中的每一行,对应提取的HTML文件内容。
3. 对每行HTML内容中的特定文本进行替换操作。
4. 将替换后的内容写入新文件,最后删除原始`list.htm`文件。
该脚本适用于需要批量处理HTML文件并进行内容替换的场景,能够提高数据处理的效率和准确性。
Set WshShell=CreateObject(“Wscript.Shell”)
WshShell.Run “cmd /c dir /s/b *.htm > list.htm”,vbHide
Wscript.Sleep 1000
Set WshShell=CreateObject(“Wscript.Shell”)
WshShell.Run “cmd /c dir /s/b *.htm > list.htm”,vbHide
Wscript.Sleep 1000
sFile=”list.htm”
Set objFSO=CreateObject(“Scripting.FileSystemObject”)
Set oFile=objFSO.OpenTextFile(sFile,1)
Do While Not oFile.AtEndOfStream
strLine=oFile.ReadLine
If Len(strLine) > 0 Then
Set File=objFSO.OpenTextFile(strLine, 1)
aryLines=File.ReadAll
File.Close
aryLines=Replace(aryLines, “需要替换的内容”, “替换后的内容”)
Set File=objFSO.OpenTextFile(strLine, 2)
File.Write aryLines
File.Close
End If
Loop
oFile.Close
objFSO.DeleteFile sFile
Set objFSO=Nothing
© 版权声明
文章版权归作者所有,未经允许请勿转载。