“退格长度根据等待秒数位长自动调整”的代码说明》
1. 命令行参数可以指定一个等待秒数,否则默认=12
2. 退格长度计算公式=2*(秒数位长+1) 对应楼主预定的显示格式》秒数位长/秒数位长
- @echo off
- if "%~1" == "" (set "n=12") else set "n=%~1"
- ::获取秒数位长
- set/p="%n%"<nul>"0.0"&for %%F in ("0.0") do (set/a "m=%%~zF,bsL=2*(m+1)")
- (del/q "0.0")&setlocal enabledelayedexpansion
- for /L %%k in (1,1,%bsL%) do (set "bs=!bs!")
- for /L %%k in (%n%,-1,0) do (
- set/p"=%%k/%n% !bs!"<nul
- timeout /t 1 >nul
- )
- endlocal&exit/b
复制代码
|