I'm writing a script which will delete old files in certain specified folders. The script logs which files it deletes, in a file called ddmmyy.log, basically day month year .log.
At the end of the script, I am writing something to clean out the old log files. Here is the script portion that I'm talking about:
Code: Select all
strScript = WScript.ScriptFullName
strScriptName = WScript.ScriptName
Set objFile = objFSO.GetFile(strScript)
objFile = CStr(objFile)
Set objParent = objFSO.GetParentFolderName(objFile)
For Each strFile In objParent.Files
If strFile = strScriptName Then
Else
strDateCreated = strFile.DateCreated
strDateSince = DateDiff("d", strDateCreated, Now)
If strDateSince > 7 Then
strFile.Delete
End If
End If
Next