Reputation: 137
I've searched already but haven't really found what I'm looking for, I just want a simple progress bar with percent complete while the batch file is downloading these lua files.
@echo off
REM The title of the CMD window
title Bot of legends LibUpdater v1.3 by Herkules101 (Updated by Bing)
REM the color of the text
color e
echo LibUpdater : The automatic library updater
echo.
echo This tool will automatically download and install BoL libraries with ease.
echo ______________________________________________________________________________
echo.
echo -- Libraries available for installation --
echo.
REM The current libraries the program will download
echo [AllClass.lua] [AoE_SkillShot_Position.lua]
echo [AQLib.lua] [BestCollision.lua]
echo [ChampionLib.lua] [Collision.lua]
echo [ComboClass.lua] [ComboLib.lua]
echo [CustomPermaShow.lua] [DataManager.lua]
echo [DRAW_POS_MANAGER.lua] [DrawDamageLib.lua]
echo [Edited_AllClass.lua] [ezCollision.lua]
echo [ezLibrary.lua] [FastCollision.lua]
echo [FTER_SOW.lua] [iLibraryENC.lua]
echo [ImBeastyLib.lua] [imLib.lua]
echo [iSAC.lua] [ITEM_MANAGER.lua]
echo [ItemRecipes.lua] [LEVEL.lua]
echo [LineSkillShotPosition.lua] [MapPosition.lua]
echo [PPrediction.lua] [Prodiction.lua]
echo [SALib.lua] [Selector.lua]
echo [ShadowVayneLib.lua] [SourceLib.lua]
echo [SOW.lua] [spellDmg.lua]
echo [spellList.lua] [SxOrbWalk.lua]
echo [VPrediction.lua] [YooLib.lua]
echo [Yolib.lua]
echo.
echo.
pause
cls
:install
REM Ask user whether they would like to Download libraries Y = goto download N = goto exit
Set /P _install= Download/update the current libraries available? (Y/N) :
If /I "%_install%"=="Y" goto download
If /I "%_install%"=="N" goto exit
) Else (
REM If the user doesn't enter Y or N (Case insensitive) this message will be displayed and the user asked to answer again.
echo Invalid argument - this program is case insensitive.
ping 123.45.67.89 -n 1 -w 1800 > nul
cls
goto install
:exit
REM Exit the program
cls
echo Exiting . . .
ping 123.45.67.89 -n 1 -w 2000 > nul
exit
:download
REM Start the download process
cls
cd Tools
REM Make temporary directory to store libraries in
mkdir temp
copy wget.exe temp
cls
echo Downloading and installing libraries . . . please stand by
cd temp
REM GitHub/BitBucket URL's // Will always download the latest version that the developer uploads.
wget --no-check-certificate -q https://raw.githubusercontent.com/SurfaceS/BoL_Studio/master/Scripts/Common/AllClass.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Dienofail/BoL/master/common/AoESkillShotPosition.lua
ren "AoESkillShotPosition.lua" "AoE_SkillShot_Position.lua"
wget --no-check-certificate -q https://raw.githubusercontent.com/bolqqq/BoLScripts/master/common/AQLib.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Dienofail/BoL/master/common/BestCollision.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/wquantum1/BoL/master/ChampionLib.lua
wget --no-check-certificate -q https://bitbucket.org/Klokje/public-klokjes-bol-scripts/raw/b891699e739f77f77fd428e74dec00b2a692fdef/Common/Collision.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/SurfaceS/BoL_Studio/master/Scripts/Common/ComboClass.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/LlamaBoL/BoL/master/Common/comboLib.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Superx321/BoL/master/common/CustomPermaShow.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/BoL-Apple/BoL/master/Common/DataManager.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/fter44/ilikeman/master/common/DRAW_POS_MANAGER.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/fter44/ilikeman/master/common/Edited_AllClass.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/soulcaliber/BoL/master/Common/ezCollision.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/soulcaliber/BoL/master/Common/ezLibrary.lua
wget --no-check-certificate -q https://bitbucket.org/boboben1/bol-scripts/raw/7dae5a6294b9db14b5430b72d9b5c2c6eb8758a1/Misc/FastCollision.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/fter44/ilikeman/master/common/FTER_SOW.lua
wget --no-check-certificate -q http://iuser99.com/libraries/iLibraryENC.lua
wget --no-check-certificate -q http://scripts.imbeasty.com/ImBeastyLib.lua
wget --no-check-certificate -q https://bitbucket.org/Klokje/public-klokjes-bol-scripts/raw/master/Common/ImLib.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/BoL-Apple/BoL/master/Common/iSAC.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/fter44/ilikeman/master/common/ITEM_MANAGER.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/fter44/ilikeman/master/common/LEVEL.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Dienofail/BoL/master/common/LineSkillShotPosition.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/c3iL/BoL-1/master/MapPosition.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Dienofail/BoL/master/common/PPrediction.lua
wget --no-check-certificate -q https://bitbucket.org/Klokje/public-klokjes-bol-scripts/raw/master/Test/Prodiction/Prodiction.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/UglyOldGuy/NintendoBoL/master/BH%20Bundle/Common/SALib.lua
wget --no-check-certificate -q http://iuser99.com/scripts/Selector.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Superx321/BoL/master/common/ShadowVayneLib.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/gbilbao/Bilbao/master/BoL1/Common/SourceLib.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/gbilbao/Bilbao/master/BoL1/Common/SOW.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/SurfaceS/BoL_Studio/master/Scripts/Common/spellList.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Superx321/BoL/master/common/SxOrbWalk.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Ralphlol/BoLGit/master/VPrediction.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Yoooooo/YoLuaProject/master/YooLib.lua
wget --no-check-certificate -q https://raw.githubusercontent.com/Yoooooo/YoLuaProjects/master/Yolib.lua
REM Pastebin Links // Will only download the pastebin links as I add them, user may not always recieve the latest version of the library untill added.
wget --no-check-certificate -q http://pastebin.com/raw.php?i=hTM4bVC6
ren "raw.php?i=hTM4bVC6" "ItemRecipes.lua"
wget --no-check-certificate -q http://pastebin.com/raw.php?i=7EDjNzuq
ren "raw.php?i=7EDjNzuq" "spellDmg.lua"
wget --no-check-certificate -q http://pastebin.com/raw.php?i=UfZ0Efax
ren "raw.php?i=UfZ0Efax" "DrawDamageLib.lua"
REM Move all of the downloaded libraries into the Scripts\Common\ folder.
xcopy "*.lua" "../../Scripts/Common" /e /y /s /i
cd..
REM Remove the temporary directory which holds the libraries.
rmdir temp /q /s
cd..
cls
REM If VPrediction.lua in Scripts\Common doesn't exist goto error
if not exist Scripts\Common\VPrediction.lua goto error
REM If VPrediction.lua exists in Scripts\Common goto success
if exist Scripts\Common\VPrediction.lua goto success
:success
REM The script successfully found VPrediction.lua leading to this message being displayed.
echo Libraries have succesfully been installed.
echo.
echo. ~ Exiting in 5 ~
ping 123.45.67.89 -n 1 -w 5000 > nul
exit
:error
REM The script couldn't find VPrediction.lua leading to this message being displayed.
echo An error has occured during the download and installation process.
echo.
echo Please ensure that the "Tools" folder is present within your BoL installation
echo If errors persist try and disable any anti-virus that may be installed.
echo The program will now exit . . .
ping 123.45.67.89 -n 1 -w 10000 > nul
I'm just starting to learn this stuff so I still don't understand alot, I'm just trying to update files I found useful but that are now abandoned and thought it would be neat to have a progress bar and percentage compete status because it takes awhile to download all the files and some people may think it froze etc. Any help would be greatly appreciated.
Upvotes: 1
Views: 11925
Reputation: 6620
Simplest solution for your situation would be to turn echo
on just before you make all your wget calls.
You would do that with @echo on
That way you can see how far your program gets or what its stuck on.
The other option would be to make a second batch file which handle the UI:
@echo off
REM The title of the CMD window
title Bot of legends LibUpdater v1.3 by Herkules101 (Updated by Bing)
REM the color of the text
color e
echo LibUpdater : The automatic library updater
echo.
echo This tool will automatically download and install BoL libraries with ease.
echo ______________________________________________________________________________
echo.
echo -- Libraries available for installation --
echo.
REM The current libraries the program will download
echo [AllClass.lua] [AoE_SkillShot_Position.lua]
echo [AQLib.lua] [BestCollision.lua]
echo [ChampionLib.lua] [Collision.lua]
echo [ComboClass.lua] [ComboLib.lua]
echo [CustomPermaShow.lua] [DataManager.lua]
echo [DRAW_POS_MANAGER.lua] [DrawDamageLib.lua]
echo [Edited_AllClass.lua] [ezCollision.lua]
echo [ezLibrary.lua] [FastCollision.lua]
echo [FTER_SOW.lua] [iLibraryENC.lua]
echo [ImBeastyLib.lua] [imLib.lua]
echo [iSAC.lua] [ITEM_MANAGER.lua]
echo [ItemRecipes.lua] [LEVEL.lua]
echo [LineSkillShotPosition.lua] [MapPosition.lua]
echo [PPrediction.lua] [Prodiction.lua]
echo [SALib.lua] [Selector.lua]
echo [ShadowVayneLib.lua] [SourceLib.lua]
echo [SOW.lua] [spellDmg.lua]
echo [spellList.lua] [SxOrbWalk.lua]
echo [VPrediction.lua] [YooLib.lua]
echo [Yolib.lua]
echo.
echo.
pause
cls
:install
REM Ask user whether they would like to Download libraries Y = goto download N = goto exit
Set /P _install= Download/update the current libraries available? (Y/N) :
If /I "%_install%"=="Y" goto download
If /I "%_install%"=="N" goto exit
) Else (
REM If the user doesn't enter Y or N (Case insensitive) this message will be displayed and the user asked to answer again.
echo Invalid argument - this program is case insensitive.
ping 123.45.67.89 -n 1 -w 1800 > nul
cls
goto install
:exit
REM Exit the program
cls
echo Exiting . . .
ping 123.45.67.89 -n 1 -w 2000 > nul
exit
:download
REM Start the download process
cls
cd Tools
REM Make temporary directory to store libraries in
mkdir temp
copy wget.exe temp
echo 0 >> .\temp\temp.txt
..\UI.bat https://raw.githubusercontent.com/SurfaceS/BoL_Studio/master/Scripts/Common/AllClass.lua
..\UI.bat https://raw.githubusercontent.com/Dienofail/BoL/master/common/AoESkillShotPosition.lua
ren "AoESkillShotPosition.lua" "AoE_SkillShot_Position.lua"
..\UI.bat https://raw.githubusercontent.com/bolqqq/BoLScripts/master/common/AQLib.lua
..\UI.bat https://raw.githubusercontent.com/Dienofail/BoL/master/common/BestCollision.lua
..\UI.bat https://raw.githubusercontent.com/wquantum1/BoL/master/ChampionLib.lua
..\UI.bat https://bitbucket.org/Klokje/public-klokjes-bol-scripts/raw/b891699e739f77f77fd428e74dec00b2a692fdef/Common/Collision.lua
..\UI.bat https://raw.githubusercontent.com/SurfaceS/BoL_Studio/master/Scripts/Common/ComboClass.lua
..\UI.bat https://raw.githubusercontent.com/LlamaBoL/BoL/master/Common/comboLib.lua
..\UI.bat https://raw.githubusercontent.com/Superx321/BoL/master/common/CustomPermaShow.lua
..\UI.bat https://raw.githubusercontent.com/BoL-Apple/BoL/master/Common/DataManager.lua
..\UI.bat https://raw.githubusercontent.com/fter44/ilikeman/master/common/DRAW_POS_MANAGER.lua
..\UI.bat https://raw.githubusercontent.com/fter44/ilikeman/master/common/Edited_AllClass.lua
..\UI.bat https://raw.githubusercontent.com/soulcaliber/BoL/master/Common/ezCollision.lua
..\UI.bat https://raw.githubusercontent.com/soulcaliber/BoL/master/Common/ezLibrary.lua
..\UI.bat https://bitbucket.org/boboben1/bol-scripts/raw/7dae5a6294b9db14b5430b72d9b5c2c6eb8758a1/Misc/FastCollision.lua
..\UI.bat https://raw.githubusercontent.com/fter44/ilikeman/master/common/FTER_SOW.lua
..\UI.bat http://iuser99.com/libraries/iLibraryENC.lua
..\UI.bat http://scripts.imbeasty.com/ImBeastyLib.lua
..\UI.bat https://bitbucket.org/Klokje/public-klokjes-bol-scripts/raw/master/Common/ImLib.lua
..\UI.bat https://raw.githubusercontent.com/BoL-Apple/BoL/master/Common/iSAC.lua
..\UI.bat https://raw.githubusercontent.com/fter44/ilikeman/master/common/ITEM_MANAGER.lua
..\UI.bat https://raw.githubusercontent.com/fter44/ilikeman/master/common/LEVEL.lua
..\UI.bat https://raw.githubusercontent.com/Dienofail/BoL/master/common/LineSkillShotPosition.lua
..\UI.bat https://raw.githubusercontent.com/c3iL/BoL-1/master/MapPosition.lua
..\UI.bat https://raw.githubusercontent.com/Dienofail/BoL/master/common/PPrediction.lua
..\UI.bat https://bitbucket.org/Klokje/public-klokjes-bol-scripts/raw/master/Test/Prodiction/Prodiction.lua
..\UI.bat https://raw.githubusercontent.com/UglyOldGuy/NintendoBoL/master/BH%20Bundle/Common/SALib.lua
..\UI.bat http://iuser99.com/scripts/Selector.lua
..\UI.bat https://raw.githubusercontent.com/Superx321/BoL/master/common/ShadowVayneLib.lua
..\UI.bat https://raw.githubusercontent.com/gbilbao/Bilbao/master/BoL1/Common/SourceLib.lua
..\UI.bat https://raw.githubusercontent.com/gbilbao/Bilbao/master/BoL1/Common/SOW.lua
..\UI.bat https://raw.githubusercontent.com/SurfaceS/BoL_Studio/master/Scripts/Common/spellList.lua
..\UI.bat https://raw.githubusercontent.com/Superx321/BoL/master/common/SxOrbWalk.lua
..\UI.bat https://raw.githubusercontent.com/Ralphlol/BoLGit/master/VPrediction.lua
..\UI.bat https://raw.githubusercontent.com/Yoooooo/YoLuaProject/master/YooLib.lua
..\UI.bat https://raw.githubusercontent.com/Yoooooo/YoLuaProjects/master/Yolib.lua
REM Pastebin Links // Will only download the pastebin links as I add them, user may not always recieve the latest version of the library untill added.
..\UI.bat http://pastebin.com/raw.php?i=hTM4bVC6
ren "raw.php?i=hTM4bVC6" "ItemRecipes.lua"
..\UI.bat http://pastebin.com/raw.php?i=7EDjNzuq
ren "raw.php?i=7EDjNzuq" "spellDmg.lua"
..\UI.bat http://pastebin.com/raw.php?i=UfZ0Efax
ren "raw.php?i=UfZ0Efax" "DrawDamageLib.lua"
REM Move all of the downloaded libraries into the Scripts\Common\ folder.
xcopy "*.lua" "../../Scripts/Common" /e /y /s /i
cd..
REM Remove the temporary directory which holds the libraries.
rmdir temp /q /s
cd..
cls
REM If VPrediction.lua in Scripts\Common doesn't exist goto error
if not exist Scripts\Common\VPrediction.lua goto error
REM If VPrediction.lua exists in Scripts\Common goto success
if exist Scripts\Common\VPrediction.lua goto success
:success
REM The script successfully found VPrediction.lua leading to this message being displayed.
echo Libraries have succesfully been installed.
echo.
echo. ~ Exiting in 5 ~
ping 123.45.67.89 -n 1 -w 5000 > nul
exit
:error
REM The script couldn't find VPrediction.lua leading to this message being displayed.
echo An error has occured during the download and installation process.
echo.
echo Please ensure that the "Tools" folder is present within your BoL installation
echo If errors persist try and disable any anti-virus that may be installed.
echo The program will now exit . . .
ping 123.45.67.89 -n 1 -w 10000 > nul
@echo off
cls
echo Downloading and installing libraries (please be patient) . . .
set /p v=< ..\temp.txt
echo %v% downloaded of 40
wget --no-check-certificate -q %1
set /a v+=1
echo %v% > ..\temp.txt
Which I haven't tested at all, but I'm willing to hope works.
But again I recommend the simple yet potent solution @echo on
.
Upvotes: 0
Reputation: 70951
Just adapted from an old answer (that had still more unneeded code!!). This answer explains the basic idea. The rest in this answer is only a lot of code to make it look better, but of course, not necessary.
@echo off
setlocal enableextensions disabledelayedexpansion
for /l %%f in (0 1 100) do (
call :drawProgressBar %%f "up test with a long text that will not fit on screen unless you have a lot of space"
)
for /l %%f in (100 -1 0) do (
call :drawProgressBar %%f "going down test"
)
for /l %%f in (0 5 100) do (
call :drawProgressBar !random! "random test"
)
rem Clean all after use
call :finalizeProgressBar 1
call :initProgressBar "|" " "
call :drawProgressBar 0 "this is a custom progress bar"
for /l %%f in (0 1 100) do (
call :drawProgressBar %%f
)
endlocal
exit /b
:drawProgressBar value [text]
if "%~1"=="" goto :eof
if not defined pb.barArea call :initProgressBar
setlocal enableextensions enabledelayedexpansion
set /a "pb.value=%~1 %% 101", "pb.filled=pb.value*pb.barArea/100", "pb.dotted=pb.barArea-pb.filled", "pb.pct=1000+pb.value"
set "pb.pct=%pb.pct:~-3%"
if "%~2"=="" ( set "pb.text=" ) else (
set "pb.text=%~2%pb.back%"
set "pb.text=!pb.text:~0,%pb.textArea%!"
)
<nul set /p "pb.prompt=[!pb.fill:~0,%pb.filled%!!pb.dots:~0,%pb.dotted%!][ %pb.pct% ] %pb.text%!pb.cr!"
endlocal
goto :eof
:initProgressBar [fillChar] [dotChar]
if defined pb.cr call :finalizeProgressBar
for /f %%a in ('copy "%~f0" nul /z') do set "pb.cr=%%a"
if "%~1"=="" ( set "pb.fillChar=#" ) else ( set "pb.fillChar=%~1" )
if "%~2"=="" ( set "pb.dotChar=." ) else ( set "pb.dotChar=%~2" )
set "pb.console.columns="
for /f "tokens=2 skip=4" %%f in ('mode con') do if not defined pb.console.columns set "pb.console.columns=%%f"
set /a "pb.barArea=pb.console.columns/2-2", "pb.textArea=pb.barArea-9"
set "pb.fill="
setlocal enableextensions enabledelayedexpansion
for /l %%p in (1 1 %pb.barArea%) do set "pb.fill=!pb.fill!%pb.fillChar%"
set "pb.fill=!pb.fill:~0,%pb.barArea%!"
set "pb.dots=!pb.fill:%pb.fillChar%=%pb.dotChar%!"
set "pb.back=!pb.fill:~0,%pb.textArea%!
set "pb.back=!pb.back:%pb.fillChar%= !"
endlocal & set "pb.fill=%pb.fill%" & set "pb.dots=%pb.dots%" & set "pb.back=%pb.back%"
goto :eof
:finalizeProgressBar [erase]
if defined pb.cr (
if not "%~1"=="" (
setlocal enabledelayedexpansion
set "pb.back="
for /l %%p in (1 1 %pb.console.columns%) do set "pb.back=!pb.back! "
<nul set /p "pb.prompt=!pb.cr!!pb.back:~1!!pb.cr!"
endlocal
)
)
for /f "tokens=1 delims==" %%v in ('set pb.') do set "%%v="
goto :eof
Upvotes: 3