Make line breaks in a ouput .txt file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
KgOlve
Posts: 14
Joined: 30 Oct 2012 06:34

Make line breaks in a ouput .txt file

#1 Post by KgOlve » 30 Oct 2012 06:38

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.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Make line breaks in a ouput .txt file

#2 Post by abc0502 » 30 Oct 2012 06:44

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

Boombox
Posts: 80
Joined: 18 Oct 2012 05:51

Re: Make line breaks in a ouput .txt file

#3 Post by Boombox » 30 Oct 2012 07:23

.
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.

KgOlve
Posts: 14
Joined: 30 Oct 2012 06:34

Re: Make line breaks in a ouput .txt file

#4 Post by KgOlve » 30 Oct 2012 07:55

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.

Post Reply