For loop variable in if statement DOS

February 2, 2011 at 04:38:28
Specs: Windows XP
Hi,

I am trying to use the output of For loop in a if statement and I am not able to get to work. Below is the code of my batch file..

@echo off
FOR /F "tokens=1-4 delims=| skip=1" %%G IN (FileList.txt) DO (
IF %%I%=="NA" (
echo %%G %%H %%I
else
echo %%G %%H %%I
)
)

This is FileList.txt

Col1|Col2|Col3|Col4
AA|AB|AC|AD
BA|BB|NA|BC
CA|CB|CC|CD
DA|DB|NA|DC

It is not getting into the IF condition at all.

Please help..

Thanks
Veeru


See More: For loop variable in if statement DOS

Report •


#1
February 2, 2011 at 06:53:41
@echo off
FOR /F "tokens=1-4 delims=| skip=1" %%G IN (FileList.txt) DO (
IF "%%I"=="NA" (
echo %%G %%H %%I
) else (
echo %%G %%H %%I
)
)

Do both if else statements perform the same action? This has no meaning!


Report •

#2
February 2, 2011 at 06:59:28
Thanks IVO..that worked just fine..

Report •
Related Solutions


Ask Question