1. but still question remains what if I put any other FOR command or any other command under this code for some different purpose, will it work ? & how it will work ? how separate next code from this.
This is a for loop and it calls a subroutine.
You can add commands to it but placement is important.
try it with the commands below and it might be clearer
@echo off
:: start herepushd "C:\test\folder"
:: this for loop sends each filename to the subroutinefor /f "delims=" %%a in ('dir /b /a-d * ') do call :next "%%a"
popd
:: this is the end of the batch file on the goto :eofecho Donepause
goto :eof
:next
:: for each filename this subroutine is executedecho The file being processed is "%~nx1"set "name=%~nx1"
set "name=%name:old=old01%"
echo The file is being renamed from "%~1" to "%name%"ren "%~1" "%name%"
:: you can add commands to change what it does or to do extra thingspause3. another question what is
goto :eof
in the code. Even if I remove it, doesn't make any difference!!!!!???
It stops the subroutine being executed one final time, after all the filenames have been sent through the subroutine.
Thanks for your comments.