jeudi 25 juin 2015

Nested FOR statement in IF ELSE

Is it possible to Nest a FOR statement in to an IF ELSE statement?

i.e

I'm reading a variable for defining a software version. Which works if there is a version Specified. However if it's blank I was it to look for the Highest folder number instead.

So far I have:

IF %Softupgradeversion%=="" (
for /f "tokens=*" %%1 in ('dir /b /ad /on *') do (set latestdir=%%1
)) ELSE (
    SET latestdir=%Softupgradeversion%
    ) 

However if the variable is blank it doesn't work and go looking for the highest folder number. I would have though it's because the ()'s in the FOR statement as well as it being in IF ELSE ()'s. Is there like an escape character that could work like ^('dir /b /ad /on *'^) for example

Aucun commentaire:

Enregistrer un commentaire