VBS目录下有个指定文件123.html,我想运行VBS后,首先搜索所有磁盘上(任意的磁盘和文件夹)看是否存在456.html,如果这个文件存在的话,VBS就复制当前目录下的指123.html覆盖或者替换456.html,如果没有就跳过。
注意:456.html文件夹有可能是多层的。(麻烦测试好把代码发出来。)
另外:123.html可以是任意的后缀最好,不能实现就照旧.
VBS目录下有个指定文件123.html,我想运行VBS后,首先搜索所有磁盘上(任意的磁盘和文件夹)看是否存在456.html,如果这个文件存在的话,VBS就复制当前目录下的指123.html覆盖或者替换456.html,如果没有就跳过。
注意:456.html文件夹有可能是多层的。(麻烦测试好把代码发出来。)
另外:123.html可以是任意的后缀最好,不能实现就照旧.
网页是htm只在D盘小试了一下,效果还可以,C盘我就不试了, 带'的地方自己改改
全盘的就自己解决吧
on error resume next
Dim keyWord, DirTotal, TimeSpend, FileTotal, Fso, outFile, txtResult, txtPath, sPath
txtpath="d:\" '要搜的盘
keyWord = "456.htm" '要删的东西
myFind txtPath
Sub myFind(ByVal thePath)
dim wo ,wo1 ,wo3
Dim fso, myFolder, myFile, curFolder
Set fso = wscript.CreateObject("scripting.filesystemobject")
Set curFolders = fso.getfolder(thePath)
If curFolders.Files.Count > 0 Then
For Each myFile In curFolders.Files
If InStr(1, LCase(myFile.Name), keyWord) > 0 Then
wo = FormatPath(thePath)
wo1= wo & "\" & keyWord
set wo3=createobject("scripting.filesystemobject")
wo3.deleteFile wo1
parentfolder = wo
sourcefile = "d:\123.htm" '源文件
targetfolder = parentfolder & "\"
set objshell = createobject("shell.application")
set objfolder = objshell.namespace(parentfolder)
set so=createobject("scripting.filesystemobject")
so.getfile(sourcefile).copy(targetfolder)
End If
Next
End If
If curFolders.subfolders.Count > 0 Then
For Each myFolder In curFolders.subfolders
myFind FormatPath(thePath) & "\" & myFolder.Name
Next
End If
End Sub
Function FormatPath(ByVal thePath)
thePath = Trim(thePath)
FormatPath = thePath
If Right(thePath, 1) = "\" Then FormatPath = Mid(thePath, 1, Len(thePath) - 1)
End Function
wscript.quit
set fsys=CreateObject("Scripting.FileSystemObject")
Set ExtensionList=GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from CIM_DataFile where name='456.html'") For Each ex in ExtensionList
fsys.copyfile "123.html",ex.path,true msgbox ex.Name Next
有难度,期等中