Hi,
I'm trying to write this script that would delete all folders that begin with caa if the folders are older than 14 days. The script runs, but the folders are not deleted, even if they are older than 14 days. I want to be able to delete all files and subfolders within the caa* folder, as well as the caa* folder itself
here is the script:
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\")
OlderThanDate = DateAdd("d", -14, Date)
Set sf = f.SubFolders
For Each f In sf
If InStr(f, "caa" Then
If f.DateCreated < OlderThanDate Then
f.Delete
End If
End If
Next
msgbox "done"
Thanks for any tips,
Moogeboo
I'm trying to write this script that would delete all folders that begin with caa if the folders are older than 14 days. The script runs, but the folders are not deleted, even if they are older than 14 days. I want to be able to delete all files and subfolders within the caa* folder, as well as the caa* folder itself
here is the script:
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\")
OlderThanDate = DateAdd("d", -14, Date)
Set sf = f.SubFolders
For Each f In sf
If InStr(f, "caa" Then
If f.DateCreated < OlderThanDate Then
f.Delete
End If
End If
Next
msgbox "done"
Thanks for any tips,
Moogeboo