|
Answer» I am attempting a task that would work if I could use (inside a batch file) the 'enhanced syntax for variable references:
%~nI - expands %I to a file name only
which I first discovered this week. I am running MS WinXP, Ver 5.1.2600 (with Svc pak 2) on a SysteMax Venture with a 3.4 GHz Pentium D, 1.00 GB of RAM.
The following is a 1-line batch file--t.bat:
for %%~nS in (*.c) do echo c51Cmd %%S NML SPV_BETA
The c51Cmd is another batch file. I will replace 'echo' with 'call' should I ever get this thing to work.
When I run it as shown, I get: > > M:\xxx>t > %~nS was unexpected at this time. > > M:\xxx> for %~nS in (*.c) do echo c51Cmd % > S NML SPV_BETA >
I had doubled the percent sign, since it had been necessary in all prior versions of Windows. I decided to remove one '%': > > M:\xxx>t > The following usage of the PATH operator in batch-parameter > substitution is invalid: %~nS in (*.c) do echo c51Cmd %S NML SPV_BETA > > > For valid formats type CALL /? or FOR /? > t was unexpected at this time. > > M:\xxx> for %~nS in (*.c) do echo c51Cmd % > S NML SPV_BETA >
I read though all the HELP I could get from windows. On one web forum I saw an inference that that the 'enhanced' features could not be used unless extended PARAMETERS were enabled. I found no WAY to query my command interpreter as to whether this was true, but did find a way to run it with them on:
cmd /E:ON for %%~nS in (*.c) do echo c51Cmd %%S NML SPV_BETA exit
No difference.
Does this feature really work, or is MicroSoft just jerking my chain? ============================================================ Gary Lynch | To send mail change no$pam in my [emailprotected]$pam.com | domain name to stacoenergy ============================================================Just one tiny mistake, the for %%S defines the variable, its after the DO that you use the variable expansion, like this below
for %%S in (*.c) do echo c51Cmd %%~nS NML SPV_BETA
GrahamQuote Does this feature really work, or is MicroSoft just jerking my chain? It works if you do it right, like Graham SAYS.
!!!!
That fixed it.
I went back through the Windows Help system. There's nothing from which I could have inferred that reversal.
(Thanks.) ============================================================ Gary Lynch | To send mail change no$pam in my [emailprotected]$pam.com | domain name to stacoenergy ============================================================I guess you just have to 'know' it
In the old days, there were no enhancements so those of us used to how it used to work saw how the enhancements were slotted in.
Good luck Graham
|