Page 1 of 1

Make line breaks in a ouput .txt file

Posted: 30 Oct 2012 06:38
by KgOlve
0 down vote favorite

Hi,
I'm wondering if i could have some help with making line breaks in an ouput .txt file made using a batch file.
Here's the beginning of my script, so you might see better what i mean:

@echo OFF
type NUL > newfile.txt
ECHO Hello, world. I am currently asking a question. > newfile.txt


I want the text to be output into the newfile.txt file looking like this:

Hello, world.
I am currently asking a question.


I have tried searching around alot, trying different suggestions that use & and ^ and ECHO and ECHO. and $'\r' but i haven't gotten anything to work. Any help would be much appreciated.

Re: Make line breaks in a ouput .txt file

Posted: 30 Oct 2012 06:44
by abc0502
This work only for the example you posted

Code: Select all

@Echo OFF
For /F "tokens=1,2* delims= " %%A in ('Type "newfile.txt"') Do (
        Echo %%A %%B
        Echo %%C
)
pause

Re: Make line breaks in a ouput .txt file

Posted: 30 Oct 2012 07:23
by Boombox
.
Just in case all you want to do is ADD a line...


Code: Select all

@echo off
echo Hello World>file.txt
echo I am currently asking a question>>file.txt



> Create file.
>> Append to file on next line.

Re: Make line breaks in a ouput .txt file

Posted: 30 Oct 2012 07:55
by KgOlve
Boombox wrote:.
Just in case all you want to do is ADD a line...


Code: Select all

@echo off
echo Hello World>file.txt
echo I am currently asking a question>>file.txt



> Create file.
>> Append to file on next line.


Yes, thank you, that's exactly what i was on the lookout for.