another FOR question

D

djc

The FOR command allows you to run a command on each %i variable.. so, when
running this the command prompt displays each instance of the command run as
well as it's output. Is there a way to suppress only the command from
displaying but allowing the output from each command to display? I'm looking
for a way to trim down and format the output.

for example using a FOR command to run a DIR on some list would look like
this:
c:\DIR element1
File Not Found

c:\DIR element2
File Not Found

c:\DIR element3
File Not Found

etc.. etc..

I'm looking for a way to only display:
File Not Found
File Not Found
File Not Found

any input is appreciated. thanks.
 
D

djc

whoops.. forgot to mention an important point. The specific need I have is
for a command that I run... its not a batch file. I know, I could make it a
batch file and problem solved. Or just type echo off before executing the
command... or to keep in on comand I could type echo of && mycommand..
either way.. thank you. echo off is the answer. For some reason I was
thinking of redirecting using 1>null or the 2>nul stuff... totally forgot
echo off can be used outside of batch files.

Thank you!
 
G

Gary Smith

For ... do @dir

The @ sign suppresses the display of the command.

djc said:
The FOR command allows you to run a command on each %i variable.. so, when
running this the command prompt displays each instance of the command run as
well as it's output. Is there a way to suppress only the command from
displaying but allowing the output from each command to display? I'm looking
for a way to trim down and format the output.
for example using a FOR command to run a DIR on some list would look like
this:
c:\DIR element1
File Not Found
c:\DIR element2
File Not Found
c:\DIR element3
File Not Found
etc.. etc..
 

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