Delete files by file 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.
 
D

Douglas J. Steele

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
 
D

Dorian

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".
 

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