Saved Bookmarks
| 1. |
Solve : Creating Text Files using DOS? |
|
Answer» Hi, I was just wondering if it's possible to create some sort of batch file that will create a text file and allow me to insert text into that file after it has been created? Hi, I was just wondering if it's possible to create some sort of batch file that will create a text file and allow me to insert text into that file after it has been created? You use the echo command in a batch file, and follow it with redirection, so that instead of echoing text to the screen, it is redirected to a file. For example: echo Some text here > textfile.txt Would create a file named textfile.txt and in it would be Some text here If the FILENAME textfile.txt already existed, it would be overwritten. Or: echo more text here >> textfile.txt would not overwrite filename of textfile.txt, but would append more text here to it. I hope this helps. Works perfectly.. Is it possible to add a paragraph of text rather than a single line? I realize that I'd have to put ECHO texttext >> text file.txt on each line, but are there parameters I can set for the entire blog? IE: ECHO "Multiple lines of text" >> "text file.txt" Thanks.. PatrickQuote from: pbisaillon on May 15, 2007, 01:48:54 PM Works perfectly.. Right. Quote but are there parameters I can set for the entire blog? Off the top of my head - no. Perhaps SOMEONE else will come along and post to confirm that. Are you working in 'dos' command line under WinXP? or real DOS? I ask because I'm reminded of something else - related, I suppose. Check out: http://home.mnet-online.de/horst.muc/wbat32.htm and look for ClipText 1.3 Could that be utilized in whatever job you are working on? If you had a ready prepared text file you could TYPE it to another text file. type file created on %date% at %time% > newtext.txt type C:\fixed\fixed-paragraph1.txt >> newtext.txt type c:\fixed\fixed-paragraph2.txt >> newtext.txt etc This the standard way of "echoing multiple lines of text" in a batch file and the only way I know of doing it without explicitly including them. pbisaillon: The type command completely slipped my mind. Try contrex's suggestion, and let us know if it does what you NEED. |
|