navigation
posts
docs
|
Clean up your windows servers
May 27th, 2009
|
Wrote a little VB script this AM. Try it if you like. Set a batch script to run it once a week.
Set fso = CreateObject("Scripting.FileSystemObject")
'root folder you want to delete from BE CAREFUL
Set f = fso.GetFolder("E:\foldername\")
Set colSubFolders = f.SubFolders
For Each objFolder in colSubFolders
ShowFiles objFolder
Next
Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files
For Each objFile In kf
'delete files older than a year
If objFile.DateLastModified < date - 365 Then
WScript.Echo objFile & " " & objFile.DateLastModified
fso.Deletefile(objFile)
End If
Next
For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub
|
|