1.

Solve : Look for specific string in file and use it?

Answer»

Here's what I want to do:

I have a file (sample.txt) that contains the setting of a variable, i.e.:

CellName=Comp1

I want to SEARCH for this variable (CellName) and use it's value (Comp1) as a value elsewhere, e.g. in a path:

cd C:\Comp1\

So FAR I can read through each line of the code USING

Code: [Select]For /f "tokens=* delims=" %%a in (sample.txt) Do (

if %%a == CellName ())
but I can't find the string I'm LOOKING for, or use it's corresponding value. Does anyone have any ideas and can help? Code: [Select] for /f "tokens=1-2 delims==" %%A in ('type %CD%\sample.txt ^| find "cellname"') do (
cd %%B
)

FB
Excellent, fair play to you.

you were nearly there, i take it that it works now?

FBYes, works well!



Discussion

No Comment Found