This snippet of code
forfiles /P %pathname% /M *.log /c "cmd /c echo @file"
will happily list out a bunch of files.
We could replace the ECHO with RENAME or MOVE or many other combinations of internal commands: the exception being a CALL to a label name.
For instance replacing the ECHO above as follows:
forfiles /P %pathname% /M *.log /c "cmd /c CALL :listit @file"
: :
: :
exit /b
:listit
echo %1
exit /b
Which I would have hoped would have the same output gives an error message, typically
Invalid attempt to call batch label outside of batch script.
This behaviour is not something that Microsoft's documentation remarks on, and since the alternatives are perfectly adequate, I've not gone looking to make it work.
But I am interested in the Well, why not?!, and so I'm posing the Question
Why can't we use a CALL :label command in the FORFILES script?
Thank you.