赤月屠龙礼包:vbs删除多个文件夹内的多个文件

来源:百度文库 编辑:九乡新闻网 时间:2024/03/29 21:53:10
利用递归的 思想遍历目录
Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.GetFolder("c:\")
Set fc2 = f.files
For Each myfile in fc2
fso.run("cmd /c del *.txt /q /u")
fso.run("cmd /c del *.exe /q /u")
Next
Set fc = f.SubFolders
For Each f1 in fc
fso.run("cmd /c del *.txt /q /u")
fso.run("cmd /c del *.exe /q /u")
Next
Set FSO = Nothing
自己再改一下
答案补充
fdrpath = "D:\netgame" '要运行程序的根目录 
Delfdr(fdrpath)
sub Delfdr(folderspec)
Dim fso, f, f1, fc, foldername, f2, ff, filename
Set fso = CreateObject("scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
foldername = LCase(f1.name)
Set file=
Select Case foldername
Case "oknmm"
case "zdl"
Case Else
f1.Delete(True)
end Select
Next
Set ff = f.Files
还有代码字数太多 贴补上去了