The thing is that, other than for readability, there doesn't seem to be any need to use different tokens at all. Tokens only retain their value within a loop, and since a loop needs to complete before the rest of the script continues, that loop is finished when control passes back to the loop above it. And since the child loop's token no longer exists, the parent loop's token is used.
This works perfectly fine;
Code: Select all
@echo off for %%F in (file*.txt) do ( echo %%F for /f "delims=" %%F in (%%F) do ( echo %%F for /l %%F in (1,1,3) do echo %%F echo %%F ))
You'd think that the second loop would screw up, since it uses %%F as both a token and a parameter, but no, it works just fine.
I'll admit that this is a bad example, but despite all three loops using %%F as the token, they all print exactly what they're supposed to print.
Granted, such code would be confusing when using multiple, nested loops, but as far as I can see, there's no valid reason that you can't use the same token for every loop.