Regouin
05-12-2005, 06:49 AM
Is there a way to programatically check the creation date of a file and when this creation date is older then say 3 months have the file deleted?
I now have a backup routine built in my program which backs up the program once every month but everytime this creates a file with the current date included in the filename, now this builds up over time and is there a way that i can have it check for the creation dates of the files (or in the filename for that matter) and have it delete all the files older then 3 months?
tia
here is the backup routine i made:
Option Explicit
Private Sub backup()
Dim fsoObj As Object
Dim Fs As Object
Set fsoObj = CreateObject("Scripting.FileSystemObject")
Set Fs = CreateObject("Scripting.FileSystemObject")
If (Day(Now())) > "23" Then Exit Sub
With fsoObj
If .FolderExists("G:\techniek\backup\") Then
Else
.CreateFolder ("G:\techniek\backup\")
End If
End WithActiveWorkbook.SaveAs ("G:\techniek\backup\Backup Onderhoudsprogramma van " & Date & ".xls")
End Sub
I now have a backup routine built in my program which backs up the program once every month but everytime this creates a file with the current date included in the filename, now this builds up over time and is there a way that i can have it check for the creation dates of the files (or in the filename for that matter) and have it delete all the files older then 3 months?
tia
here is the backup routine i made:
Option Explicit
Private Sub backup()
Dim fsoObj As Object
Dim Fs As Object
Set fsoObj = CreateObject("Scripting.FileSystemObject")
Set Fs = CreateObject("Scripting.FileSystemObject")
If (Day(Now())) > "23" Then Exit Sub
With fsoObj
If .FolderExists("G:\techniek\backup\") Then
Else
.CreateFolder ("G:\techniek\backup\")
End If
End WithActiveWorkbook.SaveAs ("G:\techniek\backup\Backup Onderhoudsprogramma van " & Date & ".xls")
End Sub