博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
删除最后一次的备份文件vbs
阅读量:4213 次
发布时间:2019-05-26

本文共 913 字,大约阅读时间需要 3 分钟。

Dim fso,s,DeleteCount
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteCount = DeleteCount + Xdelete(fso, "E:\baktest")
MsgBox "删除了" & DeleteCount & "个文件!"
Function Xdelete(fso, source)
Dim f0,f,DeleteCount,s,f2
Set s = fso.GetFolder(source)
'f0=s.datelastmodified '获取当前文件夹的最新更新时间 datelastmodified   DateCreated
f0="2000-01-01 00:00:00"
For Each f2 In s.Files
  'msgbox "begin "
  If datediff("s",f0,f2.datelastmodified)>0 and right(f2.name,4) = ".bak" Then 
  'msgbox f2.name & f2.datelastmodified &f0
  f0=f2.datelastmodified  'datelastmodified   DateCreated
  
  End if
Next
'Msgbox f0
DeleteCount = 0
For Each f In s.Files
  If datediff("s",f.datelastmodified ,f0)>0  Then  ' datelastmodified   DateCreated
  f.Delete   False  '删除文件
 ' msgbox f.name & f.datelastmodified &f0
  DeleteCount = DeleteCount + 1
  End if
Next
For Each f In s.SubFolders
   DeleteCount = DeleteCount + Xdelete(fso, f.Path)
Next
Xdelete=DeleteCount
End Function

转载地址:http://xafmi.baihongyu.com/

你可能感兴趣的文章
从内核看epoll的实现(基于5.9.9)
查看>>
python与正则表达式
查看>>
安装.Net Framework 4.7.2时出现“不受信任提供程序信任的根证书中终止”的解决方法
查看>>
input type=“button“与input type=“submit“的区别
查看>>
解决Github代码下载慢问题!
查看>>
1.idea中Maven创建项目及2.对idea中生命周期的理解3.pom文件夹下groupId、artifactId含义
查看>>
LeetCode-栈|双指针-42. 接雨水
查看>>
stdin,stdout,stderr详解
查看>>
Linux文件和设备编程
查看>>
文件描述符
查看>>
终端驱动程序:几个简单例子
查看>>
登录linux密码验证很慢的解决办法
查看>>
fcntl函数总结
查看>>
HTML条件注释
查看>>
内核态与用户态
查看>>
使用mingw(fedora)移植virt-viewer
查看>>
趣链 BitXHub跨链平台 (4)跨链网关“初介绍”
查看>>
C++ 字符串string操作
查看>>
MySQL必知必会 -- 了解SQL和MySQL
查看>>
MySQL必知必会 -- 使用MySQL
查看>>