Code:
On Error Resume Next
Set oFileSys = WScript.CreateObject("Scripting.FileSystemObject")
sRoot = "C:\PATH"
today = Date
nMaxFileAge = 1
DeleteFiles(sRoot)
Function DeleteFiles(ByVal sFolder)
Set oFolder = oFileSys.GetFolder(sFolder)
Set aFiles = oFolder.Files
Set aSubFolders = oFolder.SubFolders
For Each file in aFiles
dFileCreated = FormatDateTime(file.DateCreated, "2")
If DateDiff("d", dFileCreated, today) > nMaxFileAge Then
file.Delete(True)
End If
Next
For Each folder in aSubFolders
DeleteFiles(folder.Path)
Next
End Function
Hey guys I'm trying to upgrade this script that he will be able to pop out msg box
with something like "hey we found files older than X, after clicking ok they will be deleted'
I simply modified this part:
Code:
For Each file in aFiles
dFileCreated = FormatDateTime(file.DateCreated, "2")
If DateDiff("d", dFileCreated, today) > nMaxFileAge Then
[b]objShell.Popup "Old file will be deleted after clicking ok",, "Warning"[/b]
file.Delete(True)
End If
but of course now I need to click on ok X times (as many files to remove)
any ideas ? ... because I'm stuck