In "Automatically Delete Old Files", I discuss DelFile.vbs, a script that you can use to delete files based on their last modified date. This script works well in deleting files in specific folders. However, my administrators wanted an additional tool to delete entire folders that were no longer used. So, I wrote the DelFolder.vbs script. DelFolder.vbs loops through all the folders in the specified root directory and deletes folders (and their contents, including subfolders) based on their last modified date. This script is useful for deleting folders that users create, then forget about. In our organization, this situation often occurs on network drives.
To use DelFolder.vbs, you need to run the script using the CScript host. The command syntax is
delfolder.vbs drive
days_since_last_modified
delete(0)_or_display(1)
where drive is the root directory you want to check. You use the days_since_last_modified argument to specify the number of days you'll allow since the last modified date. You use the last parameter to indicate whether you want to just display the folders (specify a value of 1, which is the default) or actually delete the folders (specify a value of 0). For example, if you want to preview folders on the D drive that haven’t been modified for at least 14 days, you'd use the command
delfolder.vbs D:\ 14 1
To delete those folders, you'd change the last parameter to 0: . . .

