@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 :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
@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
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