'-------------- CleanUp.vbs --------------------
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFiles fso.GetFolder("C:\Test") '<----- Change this folder name to match with your case.
Sub DeleteFiles(srcFolder)
Dim srcFile
If srcFolder.Files.Count = 0 Then
Wscript.Echo "No File to Delete"
Exit Sub
End If
For Each srcFile in srcFolder.Files
If DateDiff("d", Now, srcFile.DateCreated) < -7 Then
fso.DeleteFile srcFile, True
End If
Next
Wscript.Echo "Files Deleted successful"
End Sub
'-----------------------------------------------
To delete files that are more than 2 hours old:
Code:
...
For Each srcFile in srcFolder.Files
If DateDiff("h", Now, srcFile.DateCreated) < -2 Then
fso.DeleteFile srcFile, True
End If
Next
...
https://secure.reg.net/Product.asp?ID=11557&r=y&sessID=%7B213AEEF4-9BC0-4899-A682-8F3F5ACACF49%7D&TemplateID=-1
http://www.watchdirectory.net/wdhelp/plugins/wdopAutoDelete.html?src=godelete
Please post back if you have any more problems or questions.