Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for progressmeter.bat

(view source code of progressmeter.bat as plain text)

  1. @ECHO OFF
  2. :: ******************************************************************
  3. :ProgressMeter
  4. :: 2007_01_10 by rholt
  5. :: core2quad@rogers.com
  6. :: This subroutine displays a progress meter in the titlebar of
  7. :: the current CMD shell window.
  8. ::
  9. :: Input: %1 must contain the current progress (0-100)
  10. :: Return: None
  11. :: ******************************************************************
  12. :: Calculate the number of vertical bars then spaces based on the percentage value passed
  13. SETLOCAL ENABLEDELAYEDEXPANSION
  14. SET ProgressPercent=%1
  15. SET /A NumBars=%ProgressPercent%/2
  16. SET /A NumSpaces=50-%NumBars%
  17.  
  18. :: Clear the progress meter image
  19. SET Meter=
  20.  
  21. :: Build the meter image using vertical bars followed by trailing spaces
  22. :: Note there is a trailing space at the end of the second line below
  23. FOR /L %%A IN (%NumBars%,-1,1) DO SET Meter=!Meter!I
  24. FOR /L %%A IN (%NumSpaces%,-1,1) DO SET Meter=!Meter! 
  25.  
  26. :: Display the progress meter in the title bar and return to the main program
  27. TITLE Progress:  [%Meter%]  %ProgressPercent%%%
  28. ENDLOCAL
  29. GOTO :EOF
  30.  

page last modified: 2024-02-26; loaded in 0.0215 seconds