Hello, I think that this will solve your problem, just save the following code as whateveryoulike.vbs and schedule it (remember: the user that runs the scheduled job must have access to the “WhatchFolder“).
Const WhatchFolder = "C:\TheFolder"
Const MaxDays = 30
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(WhatchFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If DateDiff("d",objFile.DateCreated,now) >= MaxDays Then
I hope this helps.
Sorry a bit late to this post but, I have some VBScript code that I use to delete and/or archive files on a number of machines… I would suggest looking at my code and using as-is or incorporating the useful code into your script.
The code is here.
Additional details about its capabilities are on this page as well.