i am sure this is something obvious, but i cant seem to figure it out, for some reason, the batch file i have pasted below always runs twice instead of once when it hits :rename. Could someone tell me what the issue here is? This is related to the 2 other questions - Looking for a way to execute a batch file once a folder hits 10 files and copy and rename files of a certain extension via batch file
Here is the batch file --- >
rem Counting files...
set /a count = 0
for /f "tokens=*" %%P IN ('dir "H:\" /A /b') do (set /a count += 1)
rem 5 or more files?
if %count% GEQ 5 call :rename
:rename
SET count=1
FOR /f "tokens=*" %%G IN ('dir /b *.jpg') DO (call :rename_next "%%G")
goto:copy
:rename_next
ren "%1" %count%.jpg
Pause
set /a count+=1
goto:eof
:copy
xcopy c:\photo\*.jpg c:\photo\files /Y
Pause