Hello everyone. I am having a problem with the Dir command not moving through the current folder to the next file. I am looking for specific files that begin with a name and when I find them, they will be copied to another folder. After the first file is found and copied, it will not move to the next file when I call Dir(). I will go to a null value for some reason. Please help. I have pasted the code below. Thanks again everyone.
manguilla
Module Module1
Sub Main()
Dim strDir As String
Dim strSource As String
Dim strNew As String
Dim strDest As String
Dim strFile As String
Dim I As Integer
Dim currFile As String
Dim compFile As String
Dim txt As String
Dim strNum As String
Dim currNum As String
Dim finNum As Integer
Dim N As Integer
Dim pos As Integer
Dim delFlag As Integer
strDir = "C:\Chad\Test\Win2000\"
strDest = "C:\Chad\Test\Captures\"
txt = "Capture"
currFile = Dir(strDest & "*.*")
If currFile <> "" Then
Do While currFile <> ""
strNum = Mid$(currFile, 1, 2)
If IsNumeric(strNum) Then
currNum = Int(strNum)
If finNum < currNum Then
finNum = currNum
End If
End If
currFile = Dir()
Loop
End If
If finNum = 0 Then
finNum = 10
Else
finNum = finNum + 1
End If
strFile = Dir(strDir & "*.*")
Do While strFile <> ""
pos = InStr(strFile, txt)
If pos > 0 Then
I = I + 1
strSource = strDir & strFile
strNew = strDest & finNum & "capture_" & I & ".log"
If Not IsFileLocked(strSource) Then
FileCopy(strSource, strNew)
delFlag = 1
'System.IO.File.Delete(strSource)
'strSource = strNew
End If
End If
'strFile = Dir(strDir & "*.*")
strFile = Dir()
If delFlag = 1 Then
System.IO.File.Delete(strSource)
delFlag = 0
End If
Loop
End Sub
manguilla
Module Module1
Sub Main()
Dim strDir As String
Dim strSource As String
Dim strNew As String
Dim strDest As String
Dim strFile As String
Dim I As Integer
Dim currFile As String
Dim compFile As String
Dim txt As String
Dim strNum As String
Dim currNum As String
Dim finNum As Integer
Dim N As Integer
Dim pos As Integer
Dim delFlag As Integer
strDir = "C:\Chad\Test\Win2000\"
strDest = "C:\Chad\Test\Captures\"
txt = "Capture"
currFile = Dir(strDest & "*.*")
If currFile <> "" Then
Do While currFile <> ""
strNum = Mid$(currFile, 1, 2)
If IsNumeric(strNum) Then
currNum = Int(strNum)
If finNum < currNum Then
finNum = currNum
End If
End If
currFile = Dir()
Loop
End If
If finNum = 0 Then
finNum = 10
Else
finNum = finNum + 1
End If
strFile = Dir(strDir & "*.*")
Do While strFile <> ""
pos = InStr(strFile, txt)
If pos > 0 Then
I = I + 1
strSource = strDir & strFile
strNew = strDest & finNum & "capture_" & I & ".log"
If Not IsFileLocked(strSource) Then
FileCopy(strSource, strNew)
delFlag = 1
'System.IO.File.Delete(strSource)
'strSource = strNew
End If
End If
'strFile = Dir(strDir & "*.*")
strFile = Dir()
If delFlag = 1 Then
System.IO.File.Delete(strSource)
delFlag = 0
End If
Loop
End Sub