61Views3Replies

Author Options:

Once again, I need Batch Help Answered


Is there a command that can count the times a code "plays/runs" and then do something with that number? such as....

@ECHO OFF
echo.
Echo Hi
Echo.
pause >nul
Echo.
:again
start Blah.txt
goto :again

If goto :again = 5 times goto :end <---- concept Idea

:end
echo.
echo now its opened 5 times
echo.
pause

Now if it went to again 5 times is there a way that i can send it another anchor in the script?

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
Prof. Pickle
Prof. Pickle

8 years ago

@echo off
set /a num=0
echo.
echo Hi
echo.
pause > nul
echo.
:again
start Blah.txt
set /a num=%num +1
If %num% NEQ 5 goto again
goto end
::
:end
echo.
echo Now it has opened 5 times
echo.
pause


Tell me if that doesn't work

0
xACIDITYx
xACIDITYx

12 years ago

You could do a sort of like (now this won't work, b/c I'm not that experienced with batch, but you can use it as inspiration)

set x=0
:again
start blah.txt
if x < 5(
set x=x+1
goto again
) else (
goto end
)
:end
exit

0
spiker
spiker

Reply 12 years ago

hmm interesting, thanks for idea, other Ideas are still welcome though