I have a batch file which automatically restart vlc.exe if the app crashes. I am also counting the number of times it crashes.
my current coding output is like:
VLC crashed for : 0 times.
VLC crashed for : 1 times.
VLC crashed for : 2 times.
VLC crashed for : 3 times.
VLC crashed for : 4 times.
However, I want my script to print the output like:
VLC crashed for : 0 times. then 1,2,3, and so on... I just want to replace the 0,1,2,3 but dont want to make new echo line.
Any idea? Thanks.
How to replace value in same line in DOS window.
Moderator: DosItHelp
Re: How to replace value in same line in DOS window.
A common way to display that is to use CLS before echoing.
The other way is to use backspaces, and is more convoluted.
The other way is to use backspaces, and is more convoluted.
Re: How to replace value in same line in DOS window.
Thnx, any code hint?
Now I'm doing "echo VLC Crashed for %count% times.
What to replace here?
Now I'm doing "echo VLC Crashed for %count% times.
What to replace here?
Re: How to replace value in same line in DOS window.
Never mind, got it working with CLS.
Re: How to replace value in same line in DOS window.
Code: Select all
@echo off
setlocal enabledelayedexpansion
(echo.N cr.txt&echo.e 100 0d 0d&echo.r cx&echo.02&echo.w 100&echo.q)|debug>NUL
:: Assign a single CR to a variable, use a textfile with 2 bytes of 0x0d, 0x0d
for /f "tokens=1" %%x in ('type cr.txt') do set "CR=%%x"
::Simple sample, count from 1 to 2000, print it on the same line
for /L %%c in ( 1,1,20000) do (
<nul set /p ".=Count: %%c!CR!"
)
echo.
Re: How to replace value in same line in DOS window.
A method to get a CR without debug, as debug is not supported on 64 bit Windows.
for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"
for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"
Re: How to replace value in same line in DOS window.
wow... thanks !k this is exactly what i was looking for.
thank you all for sharing insights.
thank you all for sharing insights.