suppressing echo is off msg

Stupid question, but why would this piece id code say Echo is off. in the output. It puts out the required output then also says echo is offin the next line...I just see echo called once?? Could someone help me get rid of 'echo is off'

Thanks

@echo off
set InputFile=in.txt
set OutputFile=out.txt
if exist "%OutputFile%" del "%OutputFile%"
for /f "skip=3 delims=" %%a in ('type "%InputFile%"') do >>"%OutputFile%" echo %%a
back to top
chetan1981Asked:
Who is Participating?
 
Brian PringleConnect With a Mentor Systems Analyst II, SCM, ERPCommented:
Did you remove the quotes around the ('type "%InputFile%"')?  Your line should be as follows.

for /f "skip=3 delims=" %%a in ('type %InputFile%') do echo %%a >> %OutputFile%
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
If %%a = nothing then all you have there is "echo".

0
 
chetan1981Author Commented:
Thx leew, so how do I make it stop before it gets to where %%a is nothing
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Brian PringleSystems Analyst II, SCM, ERPCommented:
Your "DO" command should actually do something.  Are you trying to echo %%a TO %OutputFile%?
0
 
chetan1981Author Commented:
yeah, just adding lines from one file to another
0
 
Brian PringleSystems Analyst II, SCM, ERPCommented:
then it should be DO echo %%a >> %OutputFile%
0
 
ghostdog74Commented:
it works fine for me. I am using win XP cmd.
0
 
chetan1981Author Commented:
I tried that....it still says echo is off
Thanks
0
 
Brian PringleSystems Analyst II, SCM, ERPCommented:
rem out that line with the FOR loop and replace it with

echo %%a

What is the output there?
0
 
Brian PringleSystems Analyst II, SCM, ERPCommented:
sorry.  won't work.  rem it out and make a copy of it, but don't include the >> %OutputFile%.

What is the output?
0
 
chetan1981Author Commented:
No output, in case it helps I am just copying line #4, the way it works now is that it skips the first 3 lines and gets the 4th line.  Maybe instead of the for loop I could just get line#4 ?

Thanks for your patience..
0
 
Brian PringleSystems Analyst II, SCM, ERPCommented:
Try removing the quotes from around %InputFile% in the FOR loop.  They would cause it to read that as a string instead of a variable.
0
 
chetan1981Author Commented:
here's the outputat the console

C:\Tmp\sql_check>set InputFile=MSSQLD004.txt

C:\Tmp\sql_check>set OutputFile=MSSQLD001.txt

C:\Tmp\sql_check>if exist "MSSQLD001.txt" del "MSSQLD001.txt"

C:\Tmp\sql_check>rem for /f "skip=3 delims=" %a in ('type "MSSQLD004.txt"')
 do echo %a>>MSSQLD001.txt

C:\Tmp\sql_check>for /F "skip=3 delims=" %a in ('type "MSSQLD004.txt"') do
echo %a

C:\Tmp\sql_check>rem type MSSQL.txt >> data1.txt

C:\Tmp\sql_check>
0
 
Steve KnightConnect With a Mentor IT ConsultancyCommented:
Try adding & goto :eof to the end to exit the loop after the fourth line has been output:

for /f "skip=3 delims=" %%a in ('type "%InputFile%"') do >>"%OutputFile%" echo %%a & goto :eof
0
 
oBdAConnect With a Mentor Commented:
That can be caused by a line that only contains spaces. Try to put a single . between the echo and the %%a:

@echo off
set InputFile=in.txt
set OutputFile=out.txt
if exist "%OutputFile%" del "%OutputFile%"
for /f "skip=3 delims=" %%a in ('type "%InputFile%"') do >>"%OutputFile%" echo.%%a

Or, if you only want the fourth line, try this:
@echo off
set InputFile=in.txt
set OutputFile=out.txt
set GetLineNumber=4
if exist "%OutputFile%" del "%OutputFile%"
for /f "tokens=1* delims=[]" %%a in ('type "%InputFile%" ^| find /v /n ""') do if "%%a"=="%GetLineNumber%" >>"%OutputFile%" echo.%%b


btpringle,
the "for /f" command is running the *command* 'type "%InputFile%"' (and processing its output), not trying to read directly from the file "%InputFile%".
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.