Код
' Здесь - папка, с которой начинать сканирование
path = "F:\TM"
killdate = date() - 3
arFiles = Array()
set fso = createobject("scripting.filesystemobject")
' True - для поиска и по поддиректориям тоже, False - только в самой директории
SelectFiles path, killdate, arFiles, true
nDeleted = 0
for n = 0 to ubound(arFiles)
on error resume next 'in case of 'in use' files...
arFiles(n).delete true
if err.number <> 0 then
wscript.echo "Unable to delete: " & arFiles(n).path
else
nDeleted = nDeleted + 1
end if
on error goto 0
next
msgbox nDeleted & " of " & ubound(arFiles)+1 _
& " eligible files were deleted"
sub SelectFiles(sPath,vKillDate,arFilesToKill,bIncludeSubFolders)
on error resume next
set folder = fso.getfolder(sPath)
set files = folder.files
for each file in files
dtlastmodified = null
on error resume Next
dtlastmodified = file.datelastmodified
on error goto 0
if not isnull(dtlastmodified) Then
if dtlastmodified < vKillDate then
count = ubound(arFilesToKill) + 1
redim preserve arFilesToKill(count)
set arFilesToKill(count) = file
end if
end if
next
if bIncludeSubFolders then
for each fldr in folder.subfolders
SelectFiles fldr.path,vKillDate,arFilesToKill,true
next
end if
end sub
Файлы не будут помещаться в корзину !!!