Setting windows enviroment variables.

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
 
G

Guest

Sorry for the incorrect boards posted in. Had a hard time finding the
correct one.

Thank you much for your help Peter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top