VBScript: Delete files older than X in sub directories

5 pts.
Tags:
VBScript
Visual Basic
I'm trying to delete files older than "X" in sub directories, but skip files if in "XXXX" subdirectory.
C:TempFolder Name delete files older than X
If C:TempFolder NameSave directory exists, skip deleting files in this folder.
Here is what I have so far, but cant figure out how to do the exclusion:
' Global FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
' Start at the root
DoFolder "D:ReckonXData"
 
' Recursive function
Sub DoFolder(strFolder)
 
    With objFSO.GetFolder(strFolder)
 
        For Each objFile In .Files
            If objFile.DateCreated < Date - 30 AND NOT isexception(fldr.name) objFile.Delete
        Next
 
        For Each objFolder In .SubFolders
            DoFolder objFolder.Path
        Next
 
 
        ' Checked every file and subfolder. If this folder is empty, remove it...
        If .Files.Count = 0 Then If .SubFolders.Count = 0 Then .Delete
 
    End With
 
End Sub
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: