ajtsystems
IS-IT--Management
Hi I have a script which deletes the files and folders within subfolders of a folder. I need to delete all folders below objFolders (C:\scripts). Here it is:
strFolder = "C:\scripts"
intDays = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolders = objFSO.GetFolder(strFolder)
Recurse objFolders
Sub recurse(ByRef objFolders)
Set objSubFolders = objFolders.SubFolders
Set objFiles = objFolders.Files
For Each File In objFiles
If File.DateLastModified < objPastDate Then
On Error Resume Next
File.Delete
End If
Next
For Each Folder In objSubFolders
recurse Folder
Next
Set objSubFolders = Nothing
Set objFiles = Nothing
end sub
Thanks
strFolder = "C:\scripts"
intDays = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolders = objFSO.GetFolder(strFolder)
Recurse objFolders
Sub recurse(ByRef objFolders)
Set objSubFolders = objFolders.SubFolders
Set objFiles = objFolders.Files
For Each File In objFiles
If File.DateLastModified < objPastDate Then
On Error Resume Next
File.Delete
End If
Next
For Each Folder In objSubFolders
recurse Folder
Next
Set objSubFolders = Nothing
Set objFiles = Nothing
end sub
Thanks