I am using the following script and its working quite well reading the files and parsing out those that have a "04/ in the line. The problem is is that some of my files have hundreds of thousands of lines and the lines that contain "04/ are at the end. Is it possible to quickly jump the pointer to the first line that contains "04/ and then start the read line or can I reverse the read line command so that it starts at the bottom (then have it in the correct order)?
----------------------------------------------------------
Dim objFSO, objFolder, colFiles, File, strDirName, objFile, objFile2, strOtherNewText, strNewText
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
strDirName = "temp"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strDirName)
Set colFiles = objFolder.Files
For Each File in colFiles
Set objTextFile = objFSO.OpenTextFile(File.Path, ForReading)
Set objTextFileheader = objFSO.OpenTextFile("header.txt", ForReading)
fileArray = Split(file.Name,".")
newFileName = fileArray(0)
strNewText = objTextFileheader.ReadLine
Do Until objTextFile.AtEndOfStream
strLine = objTextFile.ReadLine
intFailure = InStr(strLine, chr(34) & "04/")
If intFailure > 0 Then
strNewText = strNewText & strLine & vbCrLf
Else
strOtherNewText = strOtherNewText & strLine & vbCrLf
End If
Loop
objTextFile.Close
objTextFileheader.Close
Set objTextFile = objFSO.OpenTextFile(newFileName&"-0407.txt" , ForWriting, True)
objTextFile.Write(strNewText)
Set objTextFile = objFSO.OpenTextFile(newFileName&"-0307.txt" , ForWriting, True)
objTextFile.Write(strOtherNewText)
objTextFile.Close
strOtherNewText = ""
strNewText = ""
Next
---------------------------------------------------------
----------------------------------------------------------
Dim objFSO, objFolder, colFiles, File, strDirName, objFile, objFile2, strOtherNewText, strNewText
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
strDirName = "temp"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strDirName)
Set colFiles = objFolder.Files
For Each File in colFiles
Set objTextFile = objFSO.OpenTextFile(File.Path, ForReading)
Set objTextFileheader = objFSO.OpenTextFile("header.txt", ForReading)
fileArray = Split(file.Name,".")
newFileName = fileArray(0)
strNewText = objTextFileheader.ReadLine
Do Until objTextFile.AtEndOfStream
strLine = objTextFile.ReadLine
intFailure = InStr(strLine, chr(34) & "04/")
If intFailure > 0 Then
strNewText = strNewText & strLine & vbCrLf
Else
strOtherNewText = strOtherNewText & strLine & vbCrLf
End If
Loop
objTextFile.Close
objTextFileheader.Close
Set objTextFile = objFSO.OpenTextFile(newFileName&"-0407.txt" , ForWriting, True)
objTextFile.Write(strNewText)
Set objTextFile = objFSO.OpenTextFile(newFileName&"-0307.txt" , ForWriting, True)
objTextFile.Write(strOtherNewText)
objTextFile.Close
strOtherNewText = ""
strNewText = ""
Next
---------------------------------------------------------