VB Script to Delete Old Backup Files.
I have created VB Script which deletes 7 days old file in Folder and Sub Folder.
iDaysOld = 7 strPath = "C:\BACKUP" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPath) Set colSubfolders = objFolder.Subfolders Set colFiles = objFolder.Files For Each objFile in colFiles If objFile.DateLastModified < (Date() - iDaysOld) Then objFile.Delete End If Next For Each objSubfolder in colSubfolders Set colFiles = objSubfolder.Files For Each objFile in colFiles If objFile.DateLastModified < (Date() - iDaysOld) Then objFile.Delete End If Next Next
Regards,
Nirav Gajjar