Q:  The article How to automatically delete folders that are n days old? is so useful. I have sub-folders such as the following:

  • D:\Reports\20051101
  • D:\Reports\ABC_20051101
  • D:\Reports\20051102
  • D:\Reports\ABC_20051102

I need to delete the folders which begin with the letters ABC. I used the same script as you suggested, but, I'm not able to delete the folders because there is no Select query. My requirement is to delete the folders start with the ABC name and the folders should be 2 days old. --Thanks, Gayatri

A: The same script can be modified slightly to accomplish this. In the last part, you may add a line of code to check if the first three characters of the folder contain string ABC.

For Each fName in fNameArray
    'This line checks if the first three chars are "ABC". If so, deletes the folder
    If left(fName,3) = "ABC" then
        FSO.DeleteFolder(BasePath & "\" & fName)
    End if
Next

Note that the above snippet is only a part of the actual code, available at this link.