windows - How to call a subroutine from `for` processed items (after `in`)? -
@echo off setlocal enabledelayedexpansion %%a in (*.*) ( set /a "pre+=1 ) /f %%a in ('call :star') ( set /a "count=count+10000" set /a "fi=10000/pre" set /a "en=!fi!*!count!" set "br=!en:~0,-6!" title !br! ) pause :star echo stuff. echo more. exit /b
i'm trying create progress bar updates while commands run. things have been working well, except need able use call command within command, , current setup (below) not working.
how can use call command in loop?
it's not possible directly call subroutine processed items.
but it's possible workaround this aacini's trick:
@echo off if /i "%1" equ "call" shift & shift & goto %2 setlocal enabledelayedexpansion %%a in (*.*) ( set /a "pre+=1 ) /f %%a in ('%0 call :star') ( set /a "count=count+10000" set /a "fi=10000/pre" set /a "en=!fi!*!count!" set "br=!en:~0,-6!" title !br! ) pause exit /b %errorlevel% :star echo stuff. echo more. exit /b
you need line if /i "%1" equ "call" shift & shift & goto %2
@ beginning of script , can call subroutine %0 call :start
form loop.
Comments
Post a Comment