公開:
スクリプトファイルと同じフォルダ内の特定拡張子のファイルをすべて削除する。
以下は削除対象拡張子が.txtの例。
Option explicit
Dim wshell
Set wshell = CreateObject("WScript.Shell")
Dim fso,fd
Set fso = CreateObject("Scripting.FileSystemObject")
Dim regexp
Set regexp = CreateObject("VBScript.RegExp")
On Error Resume Next
For Each fd In fso.GetFolder(fso.GetAbsolutePathName(".\")).Files
regexp.Pattern = "^.+\.txt$"
if regexp.Test(fd.Name) Then
fso.DeleteFile(fd)
end if
next
msgbox "完了"