Example 1. Print the bar within the window with '#' as the default filling character
call :progressbar 50
Example 2. The same as above but with an another filling character
call :progressbar 50 *
Example 3. Print the bar in the window title
set progressbar_t=1
call :progressbar 50
SOURCE
rem Prints the simple progress bar within the DOS window or in the window title
rem
rem @usage call :progressbar INTEGER [ STRING ]
rem
rem @param INTEGER The length of the progress bar
rem @param STRING Optional non-empty value defines the another filling character
:progressbar
setlocal
set progressbar_c=%~2
if not defined progressbar_c (
set progressbar_c=#
) else (
set progressbar_c=%progressbar_c:~0,1%
)
set progressbar_s=
set /a progressbar_i=%~1
:progressbar_1
set progressbar_s=%progressbar_s%%progressbar_c%
if not defined progressbar_t (
cls
echo %progressbar_s%
) else (
title %progressbar_s%
)
ping localhost -n 1 >nul
set /a progressbar_i-=1
if %progressbar_i% gtr 0 goto progressbar_1
endlocal
goto :EOF
No comments:
Post a Comment