批量文件进度百分比

如何以百分比显示Windows批处理(cmd)文件中长时间运行的操作的进度? 你能分享一些示例代码吗?

Solutions Collecting From Web of "批量文件进度百分比"

这是如何…

注意:这个代码是这个答案稍微修改的版本。

@echo off for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a" FOR /L %%n in (1,1,10) DO ( call :show_progress %%n 10 ping localhost -n 2 > nul ) echo Done! exit /b :show_progress setlocal EnableDelayedExpansion set current_step=%1 set total_steps=%2 set /a "progress=(current_step * 100) / total_steps" set /p ".=Progress: !progress!%%!CR!" <nul if !progress! equ 100 echo. exit /b