Assigning values to variables

July 22, 2010 at 05:39:51
Specs: Windows Vista

My aim is to look for the value "error" in the file "output.txt" and assign its line number to a variable.

The problem with the below script is that after executing it, "K.%f%" is always "K.0". I want it to get incemented as K.1, K.2 etc., but that doesnt happen..

SetLocal EnableDelayedExpansion
set f=0
for /f "tokens=1 delims=[]" %a in ('find /n "error" ^< d:\output.txt') do (
set /a f+=1
set /a K.%f% = %a

Can any one help me on this?


See More: Assigning values to variables

Report •

July 22, 2010 at 06:33:28

set /a K.%f% = %a


set /a K.!f! = %a

when using delayed expansion.

When your only tool is a hammer, every problem looks like a nail.

Report •
Related Solutions

Ask Question