一个可以删除指定天数文件的vbs脚本
程序员文章站
2022-07-04 21:58:24
复制代码 代码如下:const filepath = "e:\log" '定义目录 set fso = ...
复制代码 代码如下:
const filepath = "e:\log" '定义目录
set fso = createobject("scripting.filesystemobject")
showsubfolders fso.getfolder(filepath)
sub showsubfolders(folder)
for each subfolder in folder.subfolders
set files = subfolder.files
if files.count <> 0 then
for each file in files
if file.datelastmodified < now - 30 then '判断是否超过30天
fso.deletefile(subfolder.path & "\" & file.name) '删除
'wscript.echo subfolder.path & "\" & file.name '显示
end if
next
end if
showsubfolders subfolder
next
end sub