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!

help parsing text file 1

Status
Not open for further replies.

jddist

IS-IT--Management
Jan 11, 2002
2
US
Help parsing text file

Any help would be much appreciated. I am new to scripting and I am trying to parse a text file to find a value and write it to a new file..

Example

The file Test.txt:

4:38 PM 1/11/2002
Volume vld3a
working.........

%/used %/total date name
---------- ---------- ------------ --------
0% ( 0%) 0% ( 0%) Jan 02 12:02 eloginfo__exvsi__recent
0% ( 0%) 0% ( 0%) Jan 02 11:02 eloginfo__01-02-2002_11.00.00
0% ( 0%) 0% ( 0%) Jan 02 10:03 eloginfo__01-02-2002_10.00.00


I want to get the elog* values written to a new file test1.txt

So test1.text would be
eloginfo__exvsi__recent
eloginfo__01-02-2002_11.00.00
eloginfo__01-02-2002_10.00.00

Here is what I have so far.

Set WshShell = CreateObject("WScript.Shell")
Const ForReading = 1, ForWriting = 2, ForAppending = 8
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.GetFile("C:\test.txt")
set ts = f.OpenAsTextStream(ForReading, -2)
TextStreamTest = ts.read(3)
Do While not ts.AtEndOfStream
myText =myText & ts.readline & vbCrLf
loop
wscript.echo mytext



Any help would be much appreciated.

Thx
Jeff
 

Set fso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set infile = fso_OpenTextFile("C:\\Dev\Scripts\Test.Txt", ForReading, TRUE)

Do While infile.AtEndOfStream = FALSE
txt = infile.ReadLine
If instr(txt,"eloginfo") > 0 then
val = right(txt, len(txt) - instr(txt,"eloginfo") + 1)
msgbox val
End If
Loop


fengshui_1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top