Progress bar

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Rafhack
Posts: 19
Joined: 23 Feb 2014 15:02

Progress bar

#1 Post by Rafhack » 13 Jun 2014 13:52

Any suggestions or improvements?


Code: Select all

@echo off
::PROGRESS BAR
setlocal enabledelayedexpansion
set /a full = 23
for /l %%a in (1,1,%full%) do (
 CALL:ADDSPACE)
for /l %%b in (1,1,%full%) do (
 set /a actu=%%b
 set /a org=!actu! * 100
 set /a org= org / full
 CALL:PROGRESS %%b
)
del _temp.bat
exit/b
:ADDSPACE
 set "fullBar=%fullBar%_"
 set "tags=%tags%#"
 exit/b
:PROGRESS
set number=%~1
set /a pct=full-number
 (
  echo/echo/[%%tags:~0,%~1%%%%fullBar:~0,%pct%%%] %org%%%%%
 )>_temp.bat
 call _temp.bat
 timeout 1 1>nul&cls

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Progress bar

#2 Post by einstein1969 » 13 Jun 2014 16:18

Hi rafhack!

nice small progress.

Why use a file? I think that you can do without using a file.

general piece of code that is in progress bars:

Code: Select all

@echo off
::PROGRESS BAR
setlocal enabledelayedexpansion
for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"
set /a full = 23
for /l %%a in (1,1,%full%) do (
 CALL:ADDSPACE)
for /l %%b in (1,1,%full%) do (
 set /a actu=%%b
 set /a org=!actu! * 100
 set /a org= org / full
 CALL:PROGRESS %%b
)
del _temp.bat
exit/b
:ADDSPACE
 set "fullBar=%fullBar%_"
 set "tags=%tags%#"
 exit/b
:PROGRESS
set number=%~1
set /a pct=full-number
 (
  echo/set/p".=[%%tags:~0,%~1%%%%fullBar:~0,%pct%%%] %org%%%%% ^!CR^!"^<nul
 )>_temp.bat
 call _temp.bat
 timeout 1 1>nul
exit/b


einstein1969

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Progress bar

#3 Post by einstein1969 » 13 Jun 2014 16:21

my recent study on progress bar:

Code: Select all

@echo off & setlocal  EnableDelayedExpansion

for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"

rem    12345678901234567890123456789012345678901234567890
set L0=__________________________________________________
set L1=°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
set L2=±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
set L3=²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
set L4=ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ

echo(

set /a max=1000+!random!

set /a parz=!max!/4, Max=parz*4

for /L %%k in (0,1,3) do (

set /a n=%%k+1
set LL0=!L%%k!

for %%n in (!n!) do set LL1=!L%%n!

For /L %%i in (1,1,!Parz!) do (


set /a rapp=%%i*50/!parz!

set /a d=50-rapp

for %%r in (!rapp!) do for %%d in (!d!) do <nul set /p "=^<!LL1:~0,%%r!!LL0:~0,%%d!^> %%i/!Max! - !Time! !CR!"
rem >nul ping -w 500 -n 1 192.0.2.0

)


einstein1969

Rafhack
Posts: 19
Joined: 23 Feb 2014 15:02

Re: Progress bar

#4 Post by Rafhack » 13 Jun 2014 16:44

Nice examples! Thank you!

Post Reply