for %a in (*.txt) do [command using %a]
instead of
for %%a in (*.txt) do [command using %%a]
Then again, maybe I'm among the freakish few that actually use for-loops
at the dos-prompt. :)
-tim
I have used them too, starting (in my case) with Dos 3.1. Your warning
is valid on old DOS shells, and is regarded as "good form" writing by
old hands like me, but IIRC, with "modern" versions of CMD.EXE, and with
NDOS.EXE, 4DOS.EXE or 4NT.EXE, you may use either %a or %%a in either
the command line or a batch file.
As tested under cmd.exe on WinXP:
:::::::::::::::::::::::::::::::::::::::::::::::::
C:\Temp>ver
Microsoft Windows XP [Version 5.1.2600]
C:\Temp>copy con x.bat
@echo off
for %f in (*.*) do @echo %f
^Z
1 file(s) copied.
C:\Temp>x.bat
f was unexpected at this time.
C:\Temp> REM check to see if it's particular to bat vs. cmd
C:\Temp>ren x.bat x.cmd
C:\Temp>x.cmd
f was unexpected at this time.
C:\Temp>for %%f in (*.*) do @echo %%f
%%f was unexpected at this time.
C:\Temp>for %f in (*.*) do @echo %f
[directory listing]
C:\Temp>copy con x.bat
@echo off
Overwrite x.bat? (Yes/No/All): y
for %f in (*.*) do @echo %f
^Z
1 file(s) copied.
C:\Temp>x.bat
[directory listing]
:::::::::::::::::::::::::::::::::::::::::::::::::
batch files do require the double percent-sign and using
for-loops on the command line directly requres a single percent-sign.
Couldn't tell you about other shells. I haven't used 4dos since
I last booted my Compaq 386SX/16 (a good 4-5 yrs ago) which is
currently serving a critical role as 3" of monitor support...but
it runs the dos version of vim :)
-tim