mercredi 7 octobre 2015

how to compare numeric variables in dos batch files

why doesn't this work?

SET FIRST=""
SET COUNT=0
FOR %%F IN (dir *.png) DO (
  IF %COUNT% NEQ 0 GOTO _skip
  SET FIRST=%%F
:_skip
  ECHO "%%F",
  SET /A COUNT=COUNT+1
)

It sets first to the last png because the IF condition fails, because COUNT - although is incremented by set /A, the IF %COUNT% doesn't ever work. Very frustrating.

Aucun commentaire:

Enregistrer un commentaire