for loop does not work in batch file - HELP

C

C C

Hello.

I'm trying to run a for loop that is in a batch file but it does not work!
But if I type the exact "for" command on the command prompt,
it works. When run in a batch file, it errors out with:
"n was unexpected at this time".

Here is the "for" loop command:

for %n in (*.TXT) do grep ITEM1 %n

What am I missing?

Thanks in advance.
 
E

Edwin vMierlo

use double % in batch files single % on command line

in a batch file, modify your variables to include an extra %, example:

for %%n in (*.TXT).... and so on

HTH,
_Edwin.
 
C

C C

Thank you. The extra % is what I'm missing.


Edwin vMierlo said:
use double % in batch files single % on command line

in a batch file, modify your variables to include an extra %, example:

for %%n in (*.TXT).... and so on

HTH,
_Edwin.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top