dim a
a=""
msgbox "点击确定开始扫描c盘,这些需要几分钟的时间"
treeIt("c:\")
set f=ofso.opentextfile("jl.txt",2,true)
f.write a
f.close
msgbox "OK"
Function TreeIt(sPath)
on error resume next
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFso.GetFolder(sPath)
Set oSubFolders = oFolder.Subfolders
Set oFiles = oFolder.Files
For Each oFile In oFiles
a=a &ofile.path &vbcrlf
Next
For Each oSubFolder In oSubFolders
TreeIt(oSubFolder.Path)
Next
End Function
用递归啊!但我懒得写递归代码,有点理不清关系。下面的代码同样可以实现你要的功能
Set obj = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from CIM_DataFile where Extension = 'zip'")For Each file in obj
if file.drive = "f:" then
createobject("scripting.filesystemobject").movefile file.name,"E:\" & file.filename & "." & file.Extension
end if
Next
na=inputbox(" 输入完整文件名"," 查找")Set fso=areateobject("scripting.filesystemobject")
getfol "d:\aux.x"
msgbox "search over"
Sub txtfile(txt)
set qq=fso.getfolder(txt)
for each mf in qq.files
If mf.name=na then
set af = fso.getfile(mf.path)
af.copy(D:\S1.txt)
end if
next
end sub
Sub getfol(pi)
set we =fso.getfolder(pi)
For each nf in we.subfolders
txtfile nf
call getfol nf
next
end sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)