Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- On Error Resume Next
- Dim oFSO, oFolder, sDirectoryPath
- Dim oFileCollection, oFile, sDir
- Dim iDaysOld
- Dim WshShell
- set WshShell = WScript.CreateObject("WScript.Shell")
- sDirectoryPath = WshShell.ExpandEnvironmentStrings("%USERPROFILE%\Downloads\Test")
- iDaysOld = 1
- Set oFSO = CreateObject("Scripting.FileSystemObject")
- Set oFolder = oFSO.GetFolder(sDirectoryPath)
- Set oFileCollection = oFolder.Files
- For each oFile in oFileCollection
- If oFile.DateLastModified < (Date() - iDaysOld) Then
- Wscript.StdOut.WriteLine "deleting .. " +oFile
- oFile.Delete(True)
- End If
- Next
- Set oFSO = Nothing
- Set oFolder = Nothing
- Set oFileCollection = Nothing
- Set oFile = Nothing
- Set WshShell = Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement