传个VBS的:- Delfdr "D:\" '你要处理的路径
- sub Delfdr(folderspec)
- Dim fso, f, f1, fc, foldername, f2, ff, filename
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set f = fso.GetFolder(folderspec)
- Set ff = f.Files
- For Each f2 in ff
- Select Case f2.name
- Case "pagefile.sys" '你想保留的文件
- Case Else
- f2.Delete(True)
- End Select
- Next
- Set fc = f.SubFolders
- For Each f1 in fc
- foldername = f1.name
- Select Case foldername
- Case "网络游戏" '你想保留的文件
- Case Else
- f1.Delete(True)
- end Select
- next
- Set FSO=NoThing
- End sub
复制代码
|