PDA

View Full Version : Directory Cleanup script (WNT)



ddraper
06-20-2002, 05:34 PM
I am looking for a way to write a script that I can run with task scheduler that will be able to delete all directories within a directory using a date qualifier (such as all directories older than 5 days). I have a fax server that takes incoming files, processes them, converts them to tiff's, stores them in a uniquely named directory, and then sends the files out. It does not have a cleanup routine so the directory (called FTP) starts getting very large very fast with these directories called rpx_____ (where _____=unique identifier). I would like to run a cleanup script to keep only those directories = or < 5 days. any help would be appreciated.

Thanks,

Dan Draper

Jama
06-21-2002, 01:18 AM
fPath = "C:\ftp"

Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.GetFolder(fPath)

If fldr.SubFolders.count > 0 Then
For Each SubFldr In Fldr.SubFolders
If (Date - SubFldr.DateCreated) > 5 Then
SubFldr.Delete
End If

Next
Else
wscript.quit
End If

Set fso = Nothing
Set fldr = Nothing

Jama