Writing mutiple lines using batch file

Microsoft Windows 7 ultimate 32-bit
March 2, 2010 at 06:29:24
Specs: Windows 7
Hello Friends,

I wish to write multiple lines using batch files to a new file..

for example,

This is line 1
This is line 2
This is line 3
.
.
.
This is line N

I know this,

ECHO This is line 1 >>temp.txt
ECHO This is line 2 >>temp.txt
ECHO This is line 3 >>temp.txt
.
.
.
ECHO This is line N >>temp.txt

What I wish to know, instead of writing echo and >>temp.txt on everyline, can we group them together like we do in shell scripting..

Regards,
Ash


See More: Writing mutiple lines using batch file

Report •


#1
March 2, 2010 at 06:38:18
You can combine the redirection, but that's it.
(ECHO This is line 1
ECHO This is line 2 
ECHO This is line 3 
.
.
.
ECHO This is line N ) >>temp.txt


Report •

#2
March 2, 2010 at 12:30:14
or, do you mean like this:
@echo off>tempfile & setlocal
set xx=whatever at beginning of file
call :out
for /L %%a in (1 1 10) do (
set xx=line %%a
call :out
)
set xx=end of file
call :out
goto :eof

:out
>> tempfile echo %xx%


Report •

#3
March 3, 2010 at 12:53:47
What you can also do, is this (it's just another way, maybe it suits the question):


------------------------
script1.cmd
------------------------
echo This is line 1
echo This is line 2
echo This is line 3
echo This is line 4


------------------------
script2.cmd
------------------------
call script1.cmd > ouput.txt


Report •
Related Solutions


Ask Question