this simple script ,shows how to delete files in a directory, older than 30 days old.

In this case delete the files that begin with “Backup” for more than 30 days from the directory D:\Backup

' ################################################################
' # cleanup-folder.vbs
' #
' # Removes all files older than 1 week
' # Authored by Jordi Colomé
' # Based on code by YellowShoe
' # Version 1.0 - Sept 23 2008
' ################################################################

Dim fso, f, f1, fc, strComments, strScanDir
' user variables
' —————————————————————-
strDir = "D:\Backup"
strDays = 30
' 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 and (Left(f1.Name, 6) = "Backup")   Then
            fso.DeleteFile(f1)
      End If
Next
'wscript.echo strComments
WScript.Quit
' eof
Facebooktwittergoogle_plusredditpinterestlinkedinmail