You are not logged in.

#1 23 Aug 2014 13:03

neodoughnut
New Member
Registered: 28 Mar 2014
Posts: 4

Correct Delimiters for using an IF Statement in a FOR Loop?

Gents,

Thanks to this website I am a lot more able with batch lines now.

I was just wondering if anyone could quickly tell me when to put my delimiters in the following line:


FOR /F "tokens=1 delims=" %m IN ('IF %%h LSS 127 (FINDSTR /i "%e.%f.%g.0" %windir%\temp\Superscopes.txt) ELSE (FINDSTR /i "%e.%f.%g.128" %windir%\temp\Superscopes.txt)') DO echo %m

Cheers

Steve

Offline

#2 23 Aug 2014 13:24

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Correct Delimiters for using an IF Statement in a FOR Loop?

It is not clear what you are attempting to do.

Offline

#3 01 Sep 2014 10:51

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Correct Delimiters for using an IF Statement in a FOR Loop?

You'd be better off with something like this (untested):

setlocal enabledelayedexpansion
IF %%h LSS 127 (set EXP="%%e.%%f.%%g.0") ELSE (set EXP="%%e.%%f.%%g.128")
FOR /F "tokens=1 delims=" %%m IN ('FINDSTR /i "!EXP!" "%windir%\temp\Superscopes.txt"') DO echo %%m
endlocal

Fixed some other bugs too.


cmd | *sh | ruby | chef

Offline

Board footer

Powered by