N/APosted on - 01/21/2013
I need a VBS script that can monitor old folders and delete their contents when they are out of date. Please tell me how I can do this.
VBS to monitoring folder older then easily work
Hi Jessica Allen,
Please find the below code to delete files older than a specific date.
Dim fileObject, folder, file, files
strDir = "Give Full path of Destination folder"
strDays = "Give number of days"
Set fileObject = CreateObject("Scripting.FileSystemObject")
Set folder = fileObject.GetFolder(strDir)
Set files = folder.Files
For Each file in files
If DateDiff("d", file.DateCreated, Date) > strDays Then
Give the path name of the folder and the number of days for which you want to delete the file.
Hope it helps