We have been looking into solutions to perform retention on IIS log to free up storage space.
We recently implemented a VBS script to run through task scheduler on a specific folder which did work successfully.
We now wanted to apply a solution for all our IIS log folders. Rather than creating a script and scheduled task for each folder, we wanted to look into a solution that could apply to a top-level folder and recursively filter down removing log files it finds in the directories below that are older than a specific age.
This is the current VBS script used for one particular folder:
sLogFolder = "D:\inetpub\wwwroot\pcrlookup_com\Online_Reports\ReportPub\Reports\LogFiles" iMaxAge = 90 'in days Set objFSO = CreateObject("Scripting.FileSystemObject") set colFolder = objFSO.GetFolder(sLogFolder) 'Set objFolder = objFSO.GetFolder(colSubfolder.Path) Set colFiles = colFolder.Files For Each objFile in colFiles if LCase(objFSO.GetExtensionName(objFile.Name)) = "xml" then iFileAge = now-objFile.DateCreated if iFileAge > (iMaxAge+1) then objFSO.deletefile objFile, True 'wscript.echo objFile.Name end if end if Next
How would I convert this to search through multiple directories where it detects .log files?