Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to do a faster research in text file

Status
Not open for further replies.

cha69os

Technical User
Feb 16, 2012
1
CA
Hi,

I'm pettry new to software programming so I hope someone can help me on this one.

I want to create a program who will search in a folder containing a lot of text file and the majority is like about 3Mb (and there's 1 new file each day). All of them looks like this :

07 FEB 2012 07:30:19.4 TEXPOIRE 95 GENER. MESSAGES POIRE

07 FEB 2012 07:30:19.4 ETAPE#13: PAUSE DANS LA SEQUENCE.

07 FEB 2012 07:30:21.4 TEXPOIRE 95 GENER. MESSAGES POIRE

07 FEB 2012 07:30:21.4 ETAPE#11: DECHARGE DE LA POIRE.

07 FEB 2012 07:30:27.9 ZS-3360C HORS 51 POSITION CENTRE COMPACT.A DECHET


I want to look in all the files in my folder and put the positive match in another file to look the result. My program is a .hta but a use vbs for language. Here what it's looks like :

<HTML>
<HEAD>
<TITLE>Application : Recherche événements Bailey</TITLE>
<HTA:APPLICATION ID = 'Bailey'>
</HEAD>

<script language="VBScript">
Sub Bouton_OnClick
Const ForReading = 1
const TristateFalse = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set folder = objFSO.GetFolder("G:\Électrique\Bailey\ALARME BAILEY\alarmes")
Set NouveauFichier = objFSO.CreateTextFile("G:\Électrique\Bailey\ALARME BAILEY\Résultat Recherche\Resultat.html")

for each file in folder.Files

Set testfile = file.OpenAsTextStream(ForReading, TristateFalse)
Do until testfile.AtEndOfStream
strSearchThis = testfile.ReadLine
If InStr(strSearchThis, Tag.value) > 0 Then
NouveauFichier.WriteLine(strSearchThis & "</p>")
End If
Loop
testfile.Close

next

NouveauFichier.writeline("</body>")
NouveauFichier.writeline("</html>")

NouveauFichier.close

end sub

</script>
<BODY>
Tag: <input type="text" name="Tag" value="Entrer votre tag ici" /><br />
<input type="button" value="Actionnez ce bouton" name="Bouton"><br />

</BODY>
</HTML>



Is there a faster way to look thru all the files and put the results in another file?

Thank you
 
Why not simply use the FIND native command ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top