So, I have the script below and it is working except when I added the "For Each oSubFolder In oFolder" statement, I am getting the error returned:
Line: 13
Char: 1
Error: Object doesn't support this property or method
Code: 800A01B6
Source: Microsoft VBScript runtime error
Line 13 is the For Each oSubFolder In oFolder statement.
============================================================
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "C:\calls\"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files
'If database log file backups are smaller than 100kb, delete them.
For each oFile in oFileCollection
If oFile.Size <= 105000 Then
oFile.Delete(True)
End If
Next
For Each oSubFolder In oFolder
RecurseFolders oSubFolder
Next
'Clean up
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing
Sub RecurseFolders(oFolder)
set oFileCollection = oFolder.Files
'If database log file backups are smaller than 100kb, delete them.
For each oFile in oFileCollection
If oFile.Size < 105000 Then
oFile.Delete(True)
End If
Next
For Each oSubFolder In oFolder
RecurseFolders oSubFolder
Next
End Sub
Ret=Msgbox("Small Call File Deletion Completed Successfully")
============================================================
Can someone tell me what I am missing for the sub-folder deletion?
Thanks,
Chad