首页  编辑  

Windows批处理中如何覆盖现有行输出,类似ANSI?

Tags: /计算机文档/脚本,批处理/   Date Created:
@echo off
echo 1B 5B>ESC.hex
Del ESC.bin >NUL 2>&1
certutil -decodehex ESC.hex ESC.bin >NUL 2>&1
Set /P ESC=<ESC.bin
set "Ansi=%ESC%1F%ESC%0J"

Echo line 1
Echo line 2
Echo line 3
Echo line 4

Timeout /t 3 >Nul

Echo %ESC%4F1st line
Timeout /t 1 >Nul
Echo 2nd line
Timeout /t 1 >Nul
Echo 3rd line
Timeout /t 1 >Nul
Echo 4th line

Echo New first Line extra long to see it's deleted, not overwritten
Timeout /t 3 >Nul
Echo %Ansi%Overwrite Line once
Timeout /t 2 >Nul
Echo %Ansi%Overwrite Line twice
Timeout /t 2 >Nul
Echo %Ansi%Overwrite Line thrice