yoinked from Google because I'm lazy too
Code:
‘ ################################################################
‘ # cleanup-folder.vbs
‘ #
‘ # Removes all files older than 1 week
‘ # Authored by Spencer Kuziw (s.kuziw-at-epic.ca)
‘ # Based on code by YellowShoe
‘ # Version 1.0 - Sept 23 2008
‘ ################################################################
Dim fso, f, f1, fc, strComments, strScanDir
‘ user variables
‘ —————————————————————-
strDir = “FULL\PATH\TO\FOLDER\TO\BE\CLEANED”
strDays = 7
‘ DO NOT EDIT BELOW THIS LINE
‘ (unless you know what you are doing)
‘——————————————————————
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(strDir)
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateCreated, Date)> strDays Then
‘strComments = strComments & f1.name & ” “ & f1.DateCreated & vbCrLf
fso.DeleteFile(f1)
End If
Next
‘wscript.echo strComments
WScript.Quit
‘ eof
Set strDir and strDays to whatever you need, job's a good'un.
EDIT - save file as a .vbs file.