我正在尝试制作一个简单的VBS脚本,该脚本将删除拖放文件夹和子文件夹中的每个.txt文件,但是,即使它没有引发任何错误,它似乎也不起作用。>
我是VBS的新手,所以这很明显。
Option Explicit
Dim objFSO, strFolder, objFile, objFolder, Folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Get the folder dropped onto our script...
strFolder = WScript.Arguments(0)
' Recursively check each file with the folder and its subfolders...
DoFolder strFolder
Sub DoFolder(strFolder)
' Check each file...
For Each objFile In objFSO.GetFolder(strFolder).Files
If Right(objFile.name, 4) = ".txt" Then
objFSO.DeleteFile(strFolder & "\" & objFile.name)
End If
Next
' Recursively check each subfolder...
For Each objFolder In objFSO.GetFolder(strFolder).SubFolders
DoFolder objFolder.Path
Next
End Sub