Log file management can be a difficult job for system administrators because not all applications include built-in features for managing their log sizes and numbers. For example, Microsoft IIS provides the ability to log HTTP and SMTP traffic but doesn't provide any built-in tools for monitoring the amount of disk space the logs use. On my servers, I periodically use Windows Explorer to sort my files by date and delete old log files. Microsoft's BadmailAdmin.wsf script is also useful for managing the size of the Badmail folder on Microsoft Exchange and IIS SMTP servers. However, I wanted a script that could manage all the log file folders on my servers, so I wrote a script called CleanDir.js to do just that.
Introducing CleanDir.js
CleanDir.js limits the size of a folder by deleting files based on the criterion you specify. You can have the script delete files older than a specified number of days (in which case there's no maximum folder size). Alternatively, you can have the script delete the oldest files to keep the folder under a specified number of megabytes (in which case, there's no age limit to the files). . . .

