Getting the value of a variables value

April 23, 2009 at 16:12:21
Specs: Windows Vista
Sorry if this was already answered but wasnt entirely sure how to word what I am looking for as I am an extreme newb in batch scripting.

Anyway using a for loop i assigned values to different varialbes if a certain string was found


my input looks like so:
Track ID 1: video (V_MPEG4/ISO/AVC)
Track ID 2: audio (A_AC3)
Track ID 3: subtitles (S_VOBSUB)
Track ID 4: subtitles (S_VOBSUB)
Track ID 5: audio (A_AC3)

set count=0
for /f (usebackq tokens=3,5) %%a in (`mkvmerge -i filename ^| grep audio ^| sed "s/\(.*\):/\1/"`) do (
if "%%c"=="(A_AC3)" (
set /a count+=1
call SetVar.bat %a REM this is an external .bat

set myvar%count%=%1

so anyway the assigning is going perfectly well. Everytime it iterates it creates a new variable to save into.
with the input above i get


my problem is I have no idea how to access those values other than writing out the whole file name, %myvar1%, which wont work in a loop.

I have tried

and a few others but i have no idea what I am doing. Any help woulld be appreciated.


See More: Getting the value of a variables value

Report •

April 23, 2009 at 21:01:43

call echo %%myvar%count%%%

or if you can use delayed expansion:

echo !myvar%count%!

If count it set in the same loop then:

call call echo %%%%myvar%%count%%%%%%


call echo !myvar%%count%%!


for /f "delims=" %%a in ("!count!") do echo !myvar%%a!

Replace echo with the appropriate commands.

Report •

April 23, 2009 at 21:31:56
Thank you

call echo %%myvar%count%%%

worked just how I needed it to

Report •

Related Solutions

Ask Question