General discussion

Locked

Needed! script to delete files xDays old

By James Schroer ·
I have a program that writes temp files out to a folder but doesn't delete them. I need something that can run automaticly that will delete any file older than 3 days (because it still may use temp files up to 3 days old). I know you can use a VB Script to do this but I don't know the first thing about that so if you tell me to use that then you better give me a good example. Or is there a utillity under the windows 2000 Resoruce kit that I could use. Anything would be great. Thanks

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by BFilmFan In reply to Needed! script to delete ...

Visual Basic code for that is available here:

http://www.freevbcode.com/ShowCode.Asp?ID=77

Does exactly what you are wanting to do.

Collapse -

by James Schroer In reply to

Couldn't get it to work but an update by the vendor now deletes these temp files.

Collapse -

by frpieper In reply to Needed! script to delete ...

Main
Sub Main

Dim Fso
Set Fso = CreateObject("Scripting.FileSystemObject")

Dim Folder
Set Folder = Fso.GetFolder("\\server\Backup\Development")

Dim Files
Set Files = Folder.files

Dim File
Dim FileDateTime

For Each File In Files
FileDateTime = File.DateLastModified
If DateDiff("D", FileDateTime, Date) >= 3 THEN
File.Delete
End If

Next

Set Fso = Nothing

End Sub

Collapse -

by James Schroer In reply to

Couldn't get it to work but an update by the vendor now deletes these temp files.

Collapse -

by James Schroer In reply to Needed! script to delete ...

This question was closed by the author

Back to Windows Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums