Batch file 如何将进度条添加到批处理文件?

Batch file 如何将进度条添加到批处理文件?,batch-file,progress-bar,Batch File,Progress Bar,我已经搜索过了,但还没有真正找到我要找的东西,我只想要一个简单的进度条,在批处理文件下载这些lua文件时,它的完成率为% @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

我已经搜索过了,但还没有真正找到我要找的东西,我只想要一个简单的进度条,在批处理文件下载这些lua文件时,它的完成率为%

    @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

我刚开始学这些东西所以我还是不太懂,我只是想更新我发现有用的文件,但这些文件现在被放弃了,我认为最好有一个进度条和百分比竞争状态,因为下载所有文件需要一段时间,有些人可能会认为它已冻结等。任何帮助都将不胜感激。

对于您的情况,最简单的解决方案是
echo
在您拨打所有wget电话之前打开

您可以使用
@echo on

这样你就可以看到你的程序走了多远,或者卡住了什么

另一个选项是创建第二个批处理文件来处理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
UI.bat(在同一文件夹中)
@echo关闭
cls
echo下载和安装库(请耐心等待)。
设置/p v=<..\temp.txt
echo%v%已下载,共40个
wget--无检查证书-q%1
设置/a v+=1
回显%v%>..\temp.txt
我根本没有测试过,但我希望它能起作用


但是,我再次推荐一个简单而有效的解决方案
@echo on

,这个解决方案是根据一个旧的答案改编的(它还有更多不需要的代码!!)。解释基本思想。这个答案中的其余部分只是为了使它看起来更好而编写的大量代码,当然,这不是必需的

@echo关闭
setlocal enableextensions disabledelayedexpansion
对于(0 1 100)do中的/l%%f(
调用:drawProgressBar%%f“带有长文本的向上测试,除非您有足够的空间,否则无法在屏幕上显示”
)
对于(100-10)do中的/l%%f(
调用:drawProgressBar%%f“下降测试”
)
对于(0 5 100)do中的/l%%f(
调用:drawProgressBar!随机!“随机测试”
)
rem使用后清洁所有设备
调用:finalizeProgressBar 1
调用:initProgressBar“|”
调用:drawProgressBar 0“这是一个自定义进度条”
对于(0 1 100)do中的/l%%f(
呼叫:drawProgressBar%%f
)
端部
退出/b
:drawProgressBar值[文本]
如果“%~1”==”转到:eof
如果未定义pb.barArea调用:initProgressBar
setlocal enableextensions enabledelayedexpansion
设置/a“pb.value=%~1%%101”、“pb.filled=pb.value*pb.barArea/100”、“pb.Dottered=pb.barArea pb.filled”、“pb.pct=1000+pb.value”
设置“pb.pct=%pb.pct:~-3%”
如果“%~2”=”(设置“pb.text=”)否则(
设置“pb.text=%~2%pb.back%”
设置“pb.text=!pb.text:~0,%pb.textArea%!”
)

终端窗口中的经典加载条问题。是的,我花了大约2个小时在谷歌上搜索它,却找不出答案(下载第一个文件后,出于某种原因退出,因此我在UI.bat的末尾添加了“暂停”,并显示“系统找不到指定的文件”。退出修复了所有错误,但在下载第一个文件后仍然关闭。通过编辑,当我在UI.bat中添加“cd temp”时,它会在temp文件夹中创建文件“temp.txt”(应该在哪里)在“工具”文件夹中,它总是创建两次。
@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