I would like to write a script that can be set up as a Scheduled Task to delete files older than 7 hours from a few folders
The folders are:
I would also like to log how many files are deleted from each folder.
I found this vbscript through Google, and am not sure if this is the best way of doing it, and how do I change the script to do what I need:
strFolder = “C:Folder”
Set objShell = CreateObject(“Shell.Application”)
Set objFolder = objShell.Namespace(strFolder)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
For Each strFileName in objFolder.Items
If len(objFSO.GetExtensionName(strFileName)) > 0 Then
Set objFile = objFSO.GetFile(strFolder & strFileName.Name)
If DateDiff(“N”,objFile.DateLastModified,Now()) > 360 Then
objFSO.DeleteFile(strFolder & strFileName.Name),True
You must be logged in to reply to this topic.
Create a free account today to participate in forum conversations, comment on posts and more.