'========================================================= ' ' DESC: Delete files in a directory older than the specified ' number of days ' ' USAGE: Call delFiles("SOURCE DIR", #DAYS) ' ' ' AUTHOR: Todd Woolums (twoolums@toddwoolums.com) ' DATE : 05/29/2004 ' VERSION: 1.0 '========================================================= Dim strCurrentDate Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") Call delFiles("\\server\share\archive", 30) Set objFSO = Nothing Sub delFiles(strFolderPath, intAge) Dim oFldr Dim oFile Set oFldr = objFSO.GetFolder(strFolderPath) For Each oFile in oFldr.Files if datediff("d", oFile.DateLastModified, Now ()) > intAge Then oFile.Delete End if Next Set oFldr = Nothing End Sub