1.11M Members

counting backup files

 
0
 

Hi

I wonder how to count the backup files I have.

If I say like this

1: making backup OK
2: making backup OK
3: now is the question
how to count the backup files
so I can remove some of them
or kill one

Bonzo

 
0
 

This backup files saved in one folder?

 
0
 

yes

under app.path
backup

 
0
 

E.g : you want to count mdb files in your app.path folder

Dim strFile As String
Dim FileCount As Integer

FileCount = 0

strFile = Dir(App.Path & "*.mdb")

Do Until strFile = ""
    FileCount = FileCount + 1
    strFile = Dir
Loop
MsgBox FileCount & " file(s)"
 
0
 

okej that's fine

how can I remove the file when it's count say 4
and I will remove the file #4 and no other

 
0
 

How you named this file?
That codes just count how many .mdb files and we don't know which file in position #4.
Actualy the Dir Function will listed and arrange the file in ascending type and order by they name.

 
0
 

okej that's fine

     sourcefile1 = App.Path & "\PhoneTel.mdb"
destinationfile1 = App.Path & "\backup\backup\PhoneTel.mdb" & Format(Now, "yymmdd_hhnn") & ".mdb"

where can I remove say #4 file in the backup

 
0
 

As i said before that we can't determine which file in position 4.
But the files always be arranged in ascending order by they name.

Say the number of files is 4 and you want to delete the file in postion 4 (the last file).
I try to put the files in listbox and accessing it by list index.

Private Sub Form_Load()

Dim strPath As String
Dim strFile As String
Dim FileCount As Integer

FileCount = 0
strPath = App.Path & "\backup\backup
strFile = Dir(strPath & "*.mdb")

Do Until strFile = ""
    FileCount = FileCount + 1
    List1.AddItem strPath & "\" & strFile
    strFile = Dir
Loop
MsgBox FileCount & " file(s)"
End Sub

Private Sub Command1_Click()
    Kill List1.List(List1.ListCount - 1)
End Sub
 
0
 

okej that's fine

     sourcefile1 = App.Path & "\PhoneTel.mdb"
destinationfile1 = App.Path & "\backup\backup\PhoneTel.mdb" & Format(Now, "yymmdd_hhnn") & ".mdb"

where can I remove say #4 file in the backup

 
0
 

I will do that instead

Thanks a lot

 
0
 

You're welcome.
Don't forget to mark as solved.

Question Answered as of 1 Year Ago by Jx_Man
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article