Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2. On Error Resume Next
  3. Dim oFSO, oFolder, sDirectoryPath
  4. Dim oFileCollection, oFile, sDir
  5. Dim iDaysOld
  6. Dim WshShell
  7.  
  8. set WshShell = WScript.CreateObject("WScript.Shell")
  9.  
  10. sDirectoryPath = WshShell.ExpandEnvironmentStrings("%USERPROFILE%\Downloads\Test")
  11.  
  12. iDaysOld = 1
  13.  
  14. Set oFSO = CreateObject("Scripting.FileSystemObject")
  15. Set oFolder = oFSO.GetFolder(sDirectoryPath)
  16. Set oFileCollection = oFolder.Files
  17.  
  18. For each oFile in oFileCollection
  19.  
  20.  If oFile.DateLastModified < (Date() - iDaysOld) Then
  21.     Wscript.StdOut.WriteLine "deleting .. " +oFile
  22.     oFile.Delete(True)
  23.  End If
  24.  
  25. Next
  26.  
  27. Set oFSO = Nothing
  28. Set oFolder = Nothing
  29. Set oFileCollection = Nothing
  30. Set oFile = Nothing
  31. Set WshShell = Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement