Delete files by file date

  • Thread starter Thread starter SHIPP
  • Start date Start date
S

SHIPP

I am working with Access 2003. I want to be able to delete all files in a
specific directory with a date prior to a date I input. Any help would be
appreciated.
 
Untested:

Dim dtmDateToDelete As Date
Dim strFolder As String
Dim strFile As String

dtmDateToDelete = #2008-10-01#
strFolder = "C:\Folder\"
strFile = Dir(strFolder & "*.*")
Do While Len(strFile) > 0
If FileDateTime(strFolder & strFile) <= dtmDateToDelete Then
Kill strFolder & strFile
End If
strFile = Dir()
Loop
 
Look at 'File Scripting Object'. Google it.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
Back
Top