批量删除 Thumbs.db 文件的 VBScript脚本
Friday, 25. July 2008, 10:39:58
Dim Shell, FSO, objRootFolder
Set Shell = WScript.CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objRootFolder = FSO.getFolder(Shell.BrowseForFolder(0, "请选择文件夹。注意:所选文件夹以下的 Thumbs.db 文件将被全部删除!", &h11))
If deleteFilesByName(objRootFolder, "Thumbs.db") Then
MsgBox RootDir + "以下的所有 Thumbs.db 文件已被删除!"
Else
MsgBox "发生错误!"
End If
'根据文件名删除文件的递归函数
Function deleteFilesByName(objRootFolder, strName)
If (objRootFolder is Nothing) Then
deleteFilesByName = False
Exit Function
End If
Dim objFolder, objFile
For Each objFile in objRootFolder.files
If objFile.Name = strName Then
objFile.Delete True
End if
Next
For Each objFolder In objRootFolder.SubFolders
deleteFilesByName objFolder, strName
Next
deleteFilesByName = true
End Function







