請用記事本保存為ANSI編碼格式
do
lnk=inputbox("請指定文件擴展名","刪除指定類型文件-黑冰製作")
if trim(lnk)=trim("") then
rst=msgbox("請指定擴展名",64+1,"黑冰製作")
if rst=2 then
exit do
end if
else
dim folder(10)
set fso=wscript.createobject("scripting.filesystemobject")
set diskes=fso.Drives '獲取系統磁盤
for each disk in diskes
if disk.drivetype=3 or disk.drivetype=2 then '检查磁盘类型,硬盘:2,U盘:1,光盘:4
set folder(1)=fso.getfolder(disk) '獲取磁盘
set files=folder(1).files '獲取文件
for each file in files
ext=fso.GetExtensionName(file) '獲取文件擴展名
ext=lcase(ext) '將擴展名改為小寫
if ext=lcase(lnk) then
fso.deletefile(file) '刪除文件
end if
next
for i=2 to 9 '設置九層循環,可刪除九層目錄下的文件
on error resume next
set subfolders=folder(i-1).subfolders
for each subfolder in subfolders '讀取子目錄
if fso.getfolder(subfolder).attributes=22 Then '如果是系統文件,則不做改變
else
set folder(i)=fso.getfolder(subfolder) '獲取子文件夾
set files=folder(i).files
for each file in files
ext2=fso.GetExtensionName(file.path)
ext2=lcase(ext2)
if ext2=lcase(lnk) then
'fso.deletefolder(subfolder)
fso.deletefile(file)
end if
next
end if
next
next
end if
next
exit do
end if
loop