First of all, might be stupid of me to say, but don't copy the "'copy from here" or the "'to here".
Second, when he says "USAGE ONLY IN COMMAND PROMPT: cscript DelOldFiles.vbs 15", do it like this:
start -> run -> type "CMD" -> click OK -> then type "cscript DelOldFiles.vbs 15".
You might need to add the path to the file to that line.
edit: Just noticed you buggered up the code, here use this:
Code:
Function DeleteOlderFiles(whichfolder)
Dim fso, f, f1, fc, n, ThresholdDate
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(whichfolder)
Set fc = f.Files
Set objArgs = WScript.Arguments
n = 0
If objArgs.Count=0 Then
howmuchdaysinpast = 0
Else
howmuchdaysinpast = -objArgs(0)
End If
ThresholdDate = DateAdd("d", howmuchdaysinpast, Date)
For Each f1 in fc
If f1.DateLastModified<ThresholdDate Then
Wscript.StdOut.WriteLine f1
f1.Delete
n = n + 1
End If
Next
Wscript.StdOut.WriteLine "Deleted " & n & " file(s)."
End Function
If Not WScript.FullName = WScript.Path & "\cscript.exe" Then
WScript.Echo "USAGE ONLY IN COMMAND PROMPT: cscript DelOldFiles.vbs 15" & vbCrLf & "15 means to delete files older than 15 days in past."
WScript.Quit 0
End If
DeleteOlderFiles(".")
Edit the very LAST line that says "DeleteOlderFiles(".")", replace the dot(.) with the folder name.
Bookmarks