批量字符串操作进度条 [英] progress bar in batch string manipulation

查看:93
本文介绍了批量字符串操作进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的code,(我试图做一个进度条,但失败了)。
http://pastebin.com/JpUT3QvY
我得到这个作为输出:条:〜0.1巴:0.2〜吧:0,3〜等等。等等。我希望它去像: *,**,** * 等基本上都是由1每1秒提高星号。
任何帮助深表AP preciated,我尝试了许多不同的结构,但失败了。
现在,我需要保持写作只是让这个过滤器,因为它要我用正确的语法,现在你可以停止阅读,因为这是完全不相干的问题多写点能接受我的问题。

 关闭@echo&放大器; SETLOCAL enabledelayedexpansion
    设置栏= **********
    一套CNT = 0
    :循环
    CLS
    集/ A CNT + = 1
    echo.Progress:条:〜0,CNT%%!
    平-N 1 www.google.com> NUL 2 - ;&放大器; 1
    如果%CNT%NEQ 10页转到:LOOP
    echo.finished。
    暂停> NUL
    退出/ B


解决方案

试试这个:

 关闭@echo&放大器; SETLOCAL enabledelayedexpansion
设置栏= **********
集/一个CNT = 0
:循环
CLS
集/ A CNT + = 1
SET!=进度条:〜0,CNT%%!
ECHO(进展:%进度%
平-N 1 www.google.com> NUL 2 - ;&放大器; 1
如果CNT%NEQ%转到10:LOOP
ECHO(成品。REM例如无CLS
< NUL集/ P=进展:
:循环
< NUL集/ P= *
平-N 1 www.google.com> NUL 2 - ;&放大器; 1
SET /计数+ = 1
如果计数%NEQ%10页转到:循环
ECHO(安培; ECHO(成品。

Here's my code, (i tried to make a progress bar but failed). http://pastebin.com/JpUT3QvY I get this as output: bar:~0,1 bar:~0,2 bar:~0,3 etc.. etc.. I want it to go like:*, **, *** etc.. basically increase the asterisk by 1 every 1 second. Any help is much appreciated, i tried many different structures but failed. Now i need to keep writing just so this filter can accept my question since it wants me to write more using proper grammar now you can stop reading as this is completely irrelevant to the question.

@echo off & setlocal enabledelayedexpansion
    set bar=**********
    set cnt=0
    :LOOP
    cls
    set /A cnt+=1
    echo.Progress:!bar:~0,%cnt%!
    ping -n 1 www.google.com > nul 2>&1
    if "%cnt%" NEQ 10 goto :LOOP
    echo.finished.
    pause > nul
    exit /b

解决方案

try this:

@echo off & setlocal enabledelayedexpansion
set "bar=**********"
set /a cnt=0
:LOOP
cls
set /A cnt+=1
SET "progressbar=!bar:~0,%cnt%!"
ECHO(Progress:%progressbar%
ping -n 1 www.google.com > nul 2>&1
if %cnt% NEQ 10 goto :LOOP
ECHO(finished.

REM example without CLS
<NUL set/p "=Progress:"
:LOOPING
<NUL set/p"=*"
ping -n 1 www.google.com > nul 2>&1
SET /a count+=1
if %count% NEQ 10 goto :LOOPING
ECHO(&ECHO(finished.

这篇关于批量字符串操作进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆