Computing.Net > Forums > Programming > New line using batch files in .txt

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

New line using batch files in .txt

Reply to Message Icon

Name: raviepic3
Date: September 8, 2008 at 20:24:37 Pacific
OS: XP
CPU/Ram: 1GB
Product: Gigabyte
Comment:

plz forgive me if this is a repeated question..i saw few other posts in which it had replies saying to use .cpp and call it in .bat file and all...


but my situvation is im appending a text file with a batch file
echo mydata1,mydata2,mydata3,____________>> C:\sample.txt

inhere wat i wanted to do is while writing these contents to sample.txt mydata1 should be on first line and mydata2 should be 2nd line and so on...


plz help me

programming newbie :)



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 8, 2008 at 21:44:12 Pacific
Reply:

@echo off
echo mydata1 >> C:\sample.txt
echo mydata2 >> C:\sample.txt
echo mydata3 >> C:\sample.txt


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: FishMonger
Date: September 8, 2008 at 23:50:04 Pacific
Reply:

@echo off

type mydata1 mydata2 mydata3 > sample.txt


0

Response Number 3
Name: Mechanix2Go
Date: September 9, 2008 at 01:19:15 Pacific
Reply:

Hi FM,

I didn't take those to be file names.

Ya never know.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: Judago
Date: September 9, 2008 at 02:39:36 Pacific
Reply:

You could also use....

(
echo mydata1
echo mydata2
echo mydata3
)>>C:\sample.txt


0

Response Number 5
Name: Mechanix2Go
Date: September 9, 2008 at 02:50:04 Pacific
Reply:

Hi Judago,

Pretty neat.

What's with the red font? It's hard enouh to see anything with this washed out new 'look'.


=====================================
If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Response Number 6
Name: Judago
Date: September 9, 2008 at 03:20:03 Pacific
Reply:

Hi Mechanix2Go,

I read that little tip at this site and it even works from the command line.

The orange font is actually supposed to make it easier to read and help distinguish between code and comment, I guess it's not working properly, any suggestions? I did it because I stopped using pre tags because the pages were stretching with long lines.


0

Response Number 7
Name: raviepic3
Date: September 9, 2008 at 03:24:58 Pacific
Reply:

thanks everybody for helping me out..


thanks a lot

programming newbie :)


0

Response Number 8
Name: Mechanix2Go
Date: September 9, 2008 at 03:25:05 Pacific
Reply:

Yeah, I avoid the pre tag for just that reason. It makes clear where the line breaks are [and aren't] but it's a real pain to scroll left and right.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 9
Name: raviepic3
Date: September 9, 2008 at 03:27:59 Pacific
Reply:

@judago

actually the purpose was served ryt :)

thanks

programming newbie :)


0

Response Number 10
Name: Razor2.3
Date: September 9, 2008 at 04:19:08 Pacific
Reply:

Hey Judago, the theory's fine (at least I don't get any complaints), but you just need to pick a darker color. Lately, I've been using #AA0000; the color here (orange / 2) is #7F4000. Might also dabble with bolding (again, like this post).


0

Response Number 11
Name: Judago
Date: September 9, 2008 at 04:38:12 Pacific
Reply:

Thanks for the input Razor2.3. I think I'll give #7F4000 a go.


0

Response Number 12
Name: FishMonger
Date: September 9, 2008 at 08:57:50 Pacific
Reply:

Hi M2 & Judago,

My preference is to use pre tags because with the coding I do, it's important to retain the proper indentation of the code, as well as the line length. I try to stay within good coding practices and keep the line width below 80 chars.

I realize that the vast majority of batch coders don't use indentation, but they do use long line lengths. I've seen some coders (not here) with line widths above 500 chars. That's insane.

As for the horizontal scrolling, you guys must be using small monitors set to 800x600. My smallest is a 17in at 1024x768 and I haven't had a scrolling issue.


0

Response Number 13
Name: Judago
Date: September 9, 2008 at 16:18:09 Pacific
Reply:

I've got a few batch's the have 800+ characters in line length :)

What good are &&, ||, nested if and for statements if we can't confuse the command interpreter by giving it commands longer than it can read?

As for my resolution it's 1024*768 on 14" crt. My problem is probably caused by my 137dpi setting and my size 20(point?) browser font.


0

Response Number 14
Name: FishMonger
Date: September 9, 2008 at 19:47:09 Pacific
Reply:

I've got a few batch's the have 800+ characters in line length :)

lol, that's nuts, but I've seen worse. A few weeks ago I was helping someone that had lines that were over 2,000 characters.


0

Response Number 15
Name: Mechanix2Go
Date: September 10, 2008 at 02:59:51 Pacific
Reply:

Line length asidr, anyone care to give a quick lesson on || ?


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 16
Name: Razor2.3
Date: September 10, 2008 at 03:04:53 Pacific
Reply:

I could say it's shorthand for IF ERRORLEVEL 1, but this thread's gone on long enough.


0

Response Number 17
Name: Mechanix2Go
Date: September 10, 2008 at 03:23:47 Pacific
Reply:

I thought I saw it used as XOR [non bitwise] but I can't make it work.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 18
Name: Razor2.3
Date: September 10, 2008 at 04:33:08 Pacific
Reply:

Fine. One example, then you need to make a new thread.

dir "IDontExist" >NUL 2>&1 && (@ECHO File Exists) || @ECHO File not there


0

Response Number 19
Name: raviepic3
Date: September 10, 2008 at 04:36:25 Pacific
Reply:

:O


i cant even able to relate wat u people talking on :(


neways tech geniuses u all

i got answer for ma post ....once again thank you all for that :)

programming newbie :)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: New line using batch files in .txt

Batch file in perl www.computing.net/answers/programming/batch-file-in-perl/13783.html

deleting files in temp folder www.computing.net/answers/programming/deleting-files-in-temp-folder/19053.html

help me i want hidden batch file in running www.computing.net/answers/programming/help-me-i-want-hidden-batch-file-in-running/19793.html