G
Guest
I'm not much familiar with scripting outside of batch files. I came across a
script that works better then batch files and I would like to use it. All it
does is cleanup the temp folder by date modified. How do I pass the %temp%
variable as the folder to use? The other thing that would be helpful is it
only handles files, is there an easy way to add folders by modified date
also, or %temp% folder is the start and check all sub-folders if they exist?..
Thanks for your knowledge.
Michael
--script--
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFilesa fso.GetFolder("%temp%")
Sub DeleteFilesa(srcFolder)
Dim srcFile
For Each srcFile in srcFolder.Files
If DateDiff("d", Now, srcFile.DateLastModified) < -7 Then
fso.DeleteFile srcFile, True
End If
Next
End Sub
script that works better then batch files and I would like to use it. All it
does is cleanup the temp folder by date modified. How do I pass the %temp%
variable as the folder to use? The other thing that would be helpful is it
only handles files, is there an easy way to add folders by modified date
also, or %temp% folder is the start and check all sub-folders if they exist?..
Thanks for your knowledge.
Michael
--script--
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFilesa fso.GetFolder("%temp%")
Sub DeleteFilesa(srcFolder)
Dim srcFile
For Each srcFile in srcFolder.Files
If DateDiff("d", Now, srcFile.DateLastModified) < -7 Then
fso.DeleteFile srcFile, True
End If
Next
End Sub