I'm not a programmer .... Technical User. I found the below script to delete files after 30 days. I hope the script will delete a folder and all its contents based on modified date
Can anyone help
Just want to delete a folder in a directory and subfolders based on modified date
It doesn't matter what date the subfolders are last modified just the main folders in the directory i'm looking at
NumberOfDaysOld = 30
strPath = "C:\Test"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPath)
Set colSubfolders = objFolder.Subfolders
Set colFiles = objFolder.Files
For Each objFile in colFiles
If objFile.DateLastModified < (Date() - NumberOfDaysOld) Then
objFile.Delete
End If
Next
For Each objSubfolder in colSubfolders
Set colFiles = objSubfolder.Files
For Each objFile in colFiles
If objFile.DateLastModified < (Date() - NumberOfDaysOld) Then
objFile.Delete
End If
Next
Next
Can anyone help
Just want to delete a folder in a directory and subfolders based on modified date
It doesn't matter what date the subfolders are last modified just the main folders in the directory i'm looking at
NumberOfDaysOld = 30
strPath = "C:\Test"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPath)
Set colSubfolders = objFolder.Subfolders
Set colFiles = objFolder.Files
For Each objFile in colFiles
If objFile.DateLastModified < (Date() - NumberOfDaysOld) Then
objFile.Delete
End If
Next
For Each objSubfolder in colSubfolders
Set colFiles = objSubfolder.Files
For Each objFile in colFiles
If objFile.DateLastModified < (Date() - NumberOfDaysOld) Then
objFile.Delete
End If
Next
Next