I assume you are using dos / nt-batch.
This is possible with the set / p command, because set / p does not print CrLf
set /p "=Executing backup...." <nul echo OK
It is also possible to erase a line with the symbol CR. Itβs important to know that the space characters at the beginning of the / p set are ignored (in Vista, not in XP), therefore! Cr! should be posted later or at the end. CR can only be displayed with delayedExpansion because% cr% works, but CR characters are deleted in the percent expansion phase (or immediately after this phase), but not in the slow expansion phase.
Example counter that uses only one line to display
@echo off setlocal EnableDelayedExpansion EnableExtensions call :CreateCR for /l %%n in (1,1,10000) do ( set /P "=Count %%n!CR!" <nul ) echo( goto :eof :CreateCR rem setlocal EnableDelayedExpansion EnableExtensions set "X=." for /L %%c in (1,1,13) DO set X=!X:~0,4094!!X:~0,4094! echo !X! > %temp%\cr.tmp echo\>> %temp%\cr.tmp for /f "tokens=2 usebackq" %%a in ("%temp%\cr.tmp") do ( endlocal set cr=%%a goto :eof ) goto :eof
EDIT: Explanation of how the variable cr is created (done with the trick)
After setting the variable X to one point (the character itself is unimportant), it is repeated to become 8188 characters with for /L %%c in (1,1,13) DO set X=!X:~0,4094!!X:~0,4094!
Then a variable, two spaces, and both CR and LF are reflected in the file with echo !X! > %temp%\cr.tmp echo !X! > %temp%\cr.tmp (note the two spaces between !X! and > , and the internal echo-internal line corrects internally)
Now we have 8192 characters, but the data buffer can only contain 8191 characters, so the last character (translation line) will be discarded!
In the next line echo\>> %temp%\cr.tmp , another CR/LF set is added to the file ( \ carriage return and line feed are not displayed in the command just for output, since echo output ECHO is ON/OFF ), this is important since a single cr cannot be read at the end of the line (in more detail).
So now the file contains <8188 .'s><SPACE><SPACE><CR><CR><LF>
for /f "tokens=2 usebackq" %%a in ("%temp%\cr.tmp") do reads the second token, delimiters are the standard space and tab, so the second token is only one cr , since the next CR/LF is removed as a standard line.
Finally, endlocal used to return to the environment without the temporary variables X , c and a existing (as in endlocal in brackets, this allows you to set cr to endlocal really affects the end of the brackets (can also be written as for /f "tokens=2 usebackq" %%a in ("%temp%\cr.tmp") do endlocal&set cr=%%a&goto :eof )
Additionally
This was my first way to create a CR character, but it needs some time and a temporary file.
Later, I saw a simpler method for extracting CR from the copy /z command.
for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a"