1.

Solve : Using Conditionals in FOR Loop?

Answer»

How do I GO about USING conditionals within a for loop. I've read that the problem I'm running into is because the IF statement is INTERPRETED before the FOR Loop but haven't found a workaround yet.

Here is what I want a BATCH file to do. Check File set flag variables based on %%i %%j

Code: [Select]@echo off
IF EXIST C:\temp.txt (
for /F "tokens=1,2 delims=," %%i IN (C:\temp.txt) DO (
if %%i==1 (
if %%j==x86 (
set x86=1
set reboot=1
)
)
)
)
echo %x86%
Unfortunately the flags never get set.Verify the content of c:\temp.txt
C:\temp.txt:

Code: [Select]1,x86
Batch (as above) output:

Code: [Select]1



Discussion

No Comment Found