I found this VBScript code on the internet that allows me to delete files in a folder when I run it:
code:
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFiles fso.GetFolder("C:\Test") '<----- Change this folder name to match with your case.
Sub DeleteFiles(srcFolder)
Dim srcFile
If srcFolder.Files.Count = 0 Then
Wscript.Echo "No File to Delete"
Exit Sub
End If
For Each srcFile in srcFolder.Files
If DateDiff("d", Now, srcFile.DateCreated) < -20 Then
fso.DeleteFile srcFile, True
End If
Next
Wscript.Echo "Files Deleted successful"
End Sub
I've used it and it works, but how can I change it so it deletes everything (files and folders) in the specified folder, and not just the files?