Greetings -
I am looking for a script that will target a specific directory (and all subdirectories within it) and will delete any files it encounters that are beyond a certain age. So I would be able to specify "30 days" since last modified and have it go delete all those files in my target path while recursing through subs.
I wrote this:
Set objFSO = CreateObject("Scripting.Fi
leSystemOb
ject")
Set objFolder = objFSO.GetFolder("c:\windo
ws\temp")
For Each efile in objFolder.Files
If DateDiff("d",eFile.DateLas
tModified,
Now) >= 1 Then
WScript.Echo "File found: " & efile
objFSO.DeleteFile(eFile)
End If
Next
However, that only takes into account the c:\windows\temp directory. How can I modify this code to include all subdirectories?
If you're going to post a code snippet, please post the ENTIRE code sample with your changes, not just lines for me to "change". That gets messy.
Thanks so much!
Start Free Trial