vbs怎么遍历C盘下所有目录包括子目录下的文件,并且记录其路径到一个文本文件

vbs怎么遍历C盘下所有目录包括子目录下的文件,并且记录其路径到一个文本文件,第1张

Set oFso = CreateObject("Scripting.FileSystemObject")

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


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12201181.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存