Posted by 20080328 on March 28, 2008 at 03:56:28:
In Reply to: Re: Any way to write to a file in DOS batch file posted by JB on March 27, 2008 at 12:43:38:
: ... how do I include line breaks?
echo.>fubar.txt
or
echo.>>fubar.txt
:... And do I have to "build" the new file line by
: line using a new line in the batch file for each
: line I want to put in the created file?
Yes, pretty much. You could do something like so (from the command line):
for %x in (apples oranges pears bananas) do echo %x>>fubar.txt
The results in fubar.txt would be:
apples
oranges
pears
bananas
To use this command from within a batch file, double-up the percent signs like so:
for %%x in (apples oranges pears bananas) do echo %%x>>fubar.txt
To learn more about the "for" command, type:
for /?
at the cmd (or command) prompt.