I realize you’ve found another answer – but the fact is that your original code was nearly correct but for a syntax error.
Your code contained the line
set /A COUNTER=%COUNTER%+1
and the syntax that would work is simply…
set /A COUNTER=COUNTER+1
See http://ss64.com/nt/set.html for all the details on the SET command. I just thought I’d add this clarification for anyone else who doesn’t have the option of using FreeDOS.