@echo off
SET count=1
FOR /f "tokens=*" %%G IN ('dir /b') DO (call :subroutine "%%G")
GOTO :eof
:subroutine
echo %count%:%1
set /a count+=1
timeout 60
GOTO :eof
pause
ASKER
@echo off
SET count=1
FOR /f "tokens=*" %%G IN ('dir /b') DO (call :subroutine "%%G")
GOTO :eof
:subroutine
echo %count%:%1
set /a count+=1
timeout 60
GOTO :eof
pause
@echo off
SET count=1
FOR /f "tokens=*" %%G IN ('dir /b') DO (call :subroutine "%%G")
GOTO :END
:subroutine
echo %count%:%1
set /a count+=1
rem timeout 60
GOTO :eof
:END
@echo END called
pause
%1 : will have the first value of %%G , which is a folder or file name in the current directory .... Will that increment behind the scene ? example %2,%3, etc....?
I also want to know when GOTO :eof applies. I see the Subroutine is Called then the next line is : GOTO :eof
ASKER
@echo off
SET count=1
FOR /f "tokens=*" %%G IN ('dir /b') DO (call :subroutine "%%G")
GOTO :END
:subroutine
echo %count%:%1
set /a count+=1
rem timeout 60
GOTO :eof
:END
@echo END called
pause
ASKER
A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.
TRUSTED BY
I’m assuming you understand what a FOR loop does (if not just ask). So, tokens=* tells the FOR not to parse up each line it reads, and just place the whole line in the loop variable, %%G in this case.
'dir /b'
The DIR command lists all files and folders in the current folder. The /B option selects “bare” format, showing only the name of the file (or full path if used with the /S option). Som no date or size information is passed to the FOR loop, just the file name.
%1
This is the way parameters to subroutines are referenced in a subroutine. When the subroutine was called a parm was passed, in this case %%G, and so in the subroutine %1 will be replaced with the value of the first parm when the subroutine was called.
On mobile right now so can’t type too much easily but hope this helps, come back with additional places you need clarification, happy to help.
~bp