Posted by: Khairey June 10, 2009
Batch File -- Sys Admins please help
Login in to Rate this Post:     0       ?        
Dude, here is another I wrote to execute on a local machine. But I would prefer above.


' This script deletes all the files on fileFolder which are 3 days older than now.

fileFolder = "C:\Documents and Settings\khairey\Local Settings\Temp"
dateToDelete = DateAdd("d",-3,Now())

Dim objFSO
Dim objFolder

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(fileFolder)

For Each file in objFolder.Files
    If file.DateCreated < dateToDelete Then
        objFSO.DeleteFile file, True
    End If
Next

Save it as deletefile.vbs

run it as c:>cscript deletefile.vbs


Read Full Discussion Thread for this article