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!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

polydegmonpolydegmon Posts: 3Member

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

FOR /F %%A IN (C:TESTlpcqparm.cfg) DO (

@ECHO %%A:~0,9%




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


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.