'This script is to find and then delete any files that are older than 45 days old
'Version 1.0
Set fso = CreateObject ("Scripting.FileSystemObject")
If WScript.Arguments.Count = 0 then
RecurseDirectory "."
Else
RecurseDirectory WScript.Arguments.Item(0)
End If
Sub Recursedirectory(strDir)
Set refFolder = fso.GetFolder(strDir)
'Process files in directory
For Each refFile in refFolder.Files
if cDate(refFile.DateCreated) <= now()-45 then
refFile.Delete
end if
Next
Then Recurse down directory tree
For Each refSubFolder in refFolder.SubFolders
RecurseDirectory refSubFolder.Path
if refSubFolder.Files.Count = 0 then
refSubFolder.Delete
End If
Next
end sub
'cscript //nologo 45days.vbs
No comments:
Post a Comment