Reading a file and searching for a string using a bat file - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Reading a file and searching for a string using a bat file

polydegmonpolydegmon Posts: 3Member
Hi,

I'm trying to read in from a file and find a certain string, once it's found i have to split it at the = and get the text to be used in a file name backup. The only thing i'm having trouble with is getting the correct string.

This is the code i'm using

[code]
@ECHO OFF
FOR /F %%A IN (C:TESTlpcqparm.cfg) DO (

@ECHO %%A:~0,9%

SET VAR=%%A
@ECHO %VAR%

)

[/code]

The echo of the %%A variable won't let me split the string to compare it and on the following line when i put it into a variable the variable always contains the last line of the file.

The input file contains the following info

&DATE=20090807
&DATE2=08072009
D&CRDACYC=D0932E
D&PRDACYC=D0932D
W&CRWKCYC=W0932
M&CRMOCYC=M0908
Q&CRQTCYC=Q0903
END-OF-FILE

Does anyone know how this could be done or why when i put the %%A into a varaible it always contains the last line of the file?


Sign In or Register to comment.