iDaysOld = 0
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "C:\Calls\"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files
'If database log file backups are older than "iDaysOld" days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
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 older than "iDaysOld" days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next
End Sub
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
I am getting a permission denied error on the:
oFile.Delete(True)
If I run the script on the parent folder, it works fine, but when I try to use it for the sub-folders, I get the error?!? Any suggestions or a way to override this error?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.