logfile = "C:\EmptyDelete.log"
set logbook = objfso.OpenTextFile(logfile, 8, true)
Call CheckDiskFile(getdrv,ext)
logbook.Close
WshShell.Popup "检查完毕!" & vbCrLf & "(c) Zero 2014",5, "谢谢使用",vbInformation+vbokOnly
Case 2: '搜索空文件夹
getdrv = InputBox("请输入需要处理的盘符"& "格式如下:E","盘符","E")
getdrv = getdrv & ":\"
logfile = "C:\EmptyDelete.log"
set logbook = objfso.OpenTextFile(logfile, 8, true)
set drive = objfso.GetDrive(getdrv)
CheckFolder drive.RootFolder
logbook.Close
WshShell.Popup "检查完毕!" & vbCrLf & "(c) Zero 2014",5, "谢谢使用",vbInformation+vbokOnly
select
Else If confirm= vbno Then
MsgBox "你会回来的!" & vbCrLf & "(c) Zero 2014" , vbOKOnly+ vbError,"提示"
WScript.Quit
If
If
'/// 主程序部分结束
'/// /////////////////////////////////////////////检查空文件部分开始////////////////////////
Function CheckDiskFile(drv,ext)
extTemp = ext
On Error Resume Next
Dim fso
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
Set drvRootFiles = fso.GetFolder(drv)
Set files = drvRootFiles.Files
For Each file In files
IsEmptyFile file,extTemp
Next
Set subfoldertemp = fso.GetFolder(drv)
Set subfolders = subfoldertemp.SubFolders
For Each subfolder In subfolders
CheckDiskFile subfolder,extTemp '递归
Next
Function
'/// 测试是否为空文件
Sub IsEmptyFile(file,ext)
OnError Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
extFile = fso.GetExtensionName(file)
If file.Size = 0 And extFile = extThen
ReportEmpty file
If
Sub
'/// 写入日志文件
FunctionReportEmpty(file)
On Error Resume Next
response = MsgBox("我们在" & vbCr & file.Path & "发现了空文件," &_
"你想删除吗?", vbYesNo + vbDefaultButton1,"提示")
If vbyes = response Then
logbook.WriteLine vbCrLf
logbook.WriteLine "[文件:]"
logbook.WriteLinefile.Path & vbCrlf & " 在 " & Now & " 被删除"
objfso.DeleteFile file, True
end If
Function
'/// /////////////////////////////////////////////检查空文件部分结束////////////////////////
'/// /////////////////////////////////////////////检查空文件夹部分开始//////////////////////
sub CheckFolder(folderobj)
on error resume Next
isEmptyFolder folderobj
for each subfolder in folderobj.subfolders
CheckFolder subfolder
Next
end Sub
sub isEmptyFolder(folderobj)
on error resume Next
if folderobj.Size=0 and err.Number=0 then
if folderobj.subfolders.Count=0 Then
ReportEmptyFolder folderobj
end If
end If
end Sub
sub ReportEmptyFolder(folderobj)
on error resume next
lastaccessed = folderobj.DateLastAccessed
on error goto 0
response = MsgBox("我们在:" & vbCr _
& folderobj.path & vbCr & "发现了空文件夹 " & "文件夹最后访问时间:" _
& vbCr & lastaccessed & vbCr _
& "你想删除这个文件夹么?", _
vbYesNoCancel + vbDefaultButton2)
if response = vbYes Then
logbook.WriteLine "[文件夹:]"
以上关于本文的内容,仅作参考!温馨提示:如遇健康、疾病相关的问题,请您及时就医或请专业人士给予相关指导!
「四川龙网」www.sichuanlong.com小编还为您精选了以下内容,希望对您有所帮助:- 电脑蓝屏代码0x000000ed如何解决
- cmd弄电脑滚绿代码的步骤教程
- TaskBuilder低代码开发工具有什么特点?
- 为什么网页变成黑白色 网站变黑白灰色的4种代码详细讲解
- 附VB.NET代码)(c# 将xml转csv C# 将XML转为Excel
- 如何鉴别翡翠a货、b货和c货?教你非常实用的几个方法
- js在for循环中使用java代码 javascript遍历对象
- 手把手教你制造KO对手的实用肌肉
- 鱼竿6.3米跟5.4米哪个更实用 钓鱼用多长的手竿合适?4.5米和6.3米哪个好?
- 破解dll查看里面源代码 dll怎么打开方式