mercredi 17 août 2016

Using if conditions at the end of a FOR loop in Batch

I have a simple for loop in a batch file I'm working on but I can't get the variables to expand correctly. the whole script is below..

setlocal enabledelayedexpansion

set track=0

FOR /f "tokens=2" %%G IN ('find "PhysicalTrackNumber" %1') DO if %track% LSS %%G set track=%%G

echo %track%

echo %1

pause

The for command pulls all the rows with the physical track number and I'm just trying to get the biggest number. IT always stays 0 though when it's comparing. I've tried with !! around my variable as well but then the script seems to do something completely different. I thought it would take the new variable.

What am I missing to compare the outputs to the previous and just get the biggest number?

Aucun commentaire:

Enregistrer un commentaire