Created
February 13, 2013 05:01
-
-
Save davidruhmann/4942410 to your computer and use it in GitHub Desktop.
[Batch]Progress Bars... (http://www.computerhope.com/forum/index.php/topic,135713.0.html)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
if "%~1"==":::" goto :spinnerThread | |
:menuLoop | |
<nul set /p menu=Select menu[1 or 2]= | |
call :GetKey | |
echo( | |
echo Pressed '!key!' | |
if !key!==1 call :menu1 | |
if !key!==2 call :menu2 | |
if !key!==2 call :menu2 | |
goto :menuLoop | |
:menu1 | |
:menu2 | |
call :spinnerStart | |
rem do some work | |
ping localhost -n 3 > nl | |
call :spinnerStop | |
echo Finished | |
exit /b | |
:spinnerStart | |
del spinnerStop.tmp > nul 2>&1 | |
start /b "" cmd /c "%~df0" ::: | |
exit /b | |
:spinnerStop | |
echo dummy > spinnerStop.tmp | |
:__spinnerStop | |
if exist spinnerStop.tmp goto :__spinnerStop | |
exit /b | |
:spinnerThread | |
for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a" | |
set "spinChars=\|/-" | |
:spinnerLoop | |
set /a "spinner=(spinner + 1) %% 4" | |
<nul set /p ".=Waiting...!spinChars:~%spinner%,1!!CR!" | |
ping localhost -n 2 > nul 2>&1 | |
if not exist spinnerStop.tmp goto :spinnerLoop | |
del spinnerStop.tmp > nul 2>&1 | |
echo( | |
exit /b | |
:GetKey | |
set "key=" | |
for /F "usebackq delims=" %%L in (`xcopy /L /w "%~f0" "%~f0" 2^>NUL`) do ( | |
if not defined key set "key=%%L" | |
) | |
set "key=%key:~-1%" | |
exit /b | |
:: by jeb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: Tom Lavedas | |
@echo off | |
setlocal | |
set "write=<nul set/p" | |
%write%=Patience, please | |
for /l %%a in (1,1,25) do ( | |
%write%=Ü | |
ping -n 2 127.0.0.1 > nul | |
) | |
echo. Thank you for waiting. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: BEGIN FILE :::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:: ProgBar.cmd | |
:: Frank P. Westlake, 2009-07-23 | |
:: Demonstrates a progress bar. | |
:: Set variable 'size' with the number of times a loop will | |
:: be accomplished. | |
@ECHO OFF | |
Echo.Bye. | |
:: Restore the computer operator's code page. | |
CHCP %CP% >NUL: | |
:: Goto :EOF. | |
Goto :EOF | |
:DoNothing | |
::Not doing anything yet . . . | |
:: Goto :EOF again. | |
Goto :EOF | |
:: END OF FILE ::::::::::::::::::::::::::::::::::::::::::::::::::: | |
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION | |
Set /A size=1234, progress=0, item=0, last=0 | |
Echo.Processing %size% items . . . | |
:: Save current code page for restoration at completion. | |
For /F "tokens=2 delims=:" %%a in ('CHCP') Do Set "CP=%%a" | |
:: Using code page 437 for the character 'Û' in the progress bar. | |
CHCP 437 >NUL: | |
:: Progress bar caption. | |
Echo. 10 20 30 40 50 60 70 80 90 100%% | |
:: 7-bit ASCII progress indicator. | |
::Set "indicator=___" | |
:: 8-bit progress indicator (Û=DBh, the inverted space character). | |
::Set "indicator=ÛÛÛ" | |
Set "indicator=±±±" | |
:: A demonstration loop. | |
For /L %%i in (0 1 %size%) Do ( | |
Set /A item+=1,progress=item*10/%size% | |
If !last! NEQ !progress! ( | |
Set /P "=!indicator!"<NUL: | |
Set /A last=progress | |
) | |
Call :DoNothing | |
) | |
:: Terminate the progress bar. | |
Echo.%indicator:~0,2% | |
:: Say bye now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
if exist stopslash.dat del stopslash.dat | |
:start | |
for %%P in (^| \ - /) do cls&echo %%P&ping localhost -n 2 | |
if exist stopslash.dat del stopslash.dat&goto endfile | |
goto start | |
:endfile | |
:: by BC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Echo OFF | |
SetLocal EnableExtensions EnableDelayedExpansion | |
For /f %%a in ('copy /Z "%~dpf0" nul') Do set "CR=%%a" | |
Set "busy=|/-\" | |
Set /A n=0 | |
::BUSY SPINNER | |
For /L %%i in (0,1,10) Do ( | |
Set /A "n=%%i%%4" | |
For /L %%n in (!n! 1 !n!) Do Set /P "=Calculating !busy:~%%n,1! !CR!"<NUL: | |
PING -n 2 127.0.0.1 >NUL: | |
) | |
::COUNTDOWN | |
For /L %%i in (10,-1,1) Do ( | |
Set /P "=Backup will begin in %%i seconds. !CR!"<NUL: | |
PING -n 2 127.0.0.1 >NUL: | |
) | |
::PROGRESS | |
For %%i in (*) Do ( | |
Set /P "=Copying %%i !CR!"<NUL: | |
PING -n 2 127.0.0.1 >NUL: | |
) | |
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
start /b slasher.bat | |
ping www.google.ca -n 8 > redirected.txt 2>&1 | |
echo "test">stopslash.dat | |
echo "finished." | |
:waitdel | |
if exist stopslash.dat goto waitdel | |
cls | |
echo Finished! | |
type redirected.txt | |
:: by BC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment