In a batch file, I want to write a "counter" to the screen without scrolling stuff off the screen. I have
FOR /L %%i IN (1,1,1000) DO (
< NUL set /P="Count= %%i"
)
{There is no space between < LT> NUL
but this stops the line from showing in the question.}
This command doesn't add a LF or CR, but I do want a CR, just no LF.
The end result should be
Count= X
where X is "counting" from 1 to 1,000.
@echo off
setlocal EnableDelayedExpansion
rem Get a Carriage Return (Ascii 13) in CR variable:
for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a"
FOR /L %%i IN (1,1,1000) DO ( < NUL set /P "=Count= %%i!CR!" )
@echo off
setlocal EnableDelayedExpansion
set cnt=0
for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a"
FOR /L %%a IN (1,1,5) DO (
call :cnt
timeout /t 1 >nul
< NUL set /P "=!er!!CR!"
)
echo.
pause
exit
:cnt
set /a cnt=!cnt!+1
if %cnt% == 1 set er=Hello!
if %cnt% == 2 set er=I am Soubhik Biswas
if %cnt% == 3 set er=My Roll Is 40
if %cnt% == 4 set er=Is Study In Class VIII-C
goto :eof