I am making a .bat
file, and I would like it to write ASCII art into a text file.
I was able to find the command to append a new line to the file when echoing text, but when I read that text file, all I see is a layout-sign and not a space. I think it would work by opening that file with Word or even WordPad, but I would like it to work on any computer, even if that computer only has Notepad (which is mostly the case).
How can I open the text file in a certain program (i.e. WordPad) or write a proper space character to the file?
EDIT:
I found that it is the best way to use:
echo <line1> > <filename>
echo <line2> >> <filename>
P.S. I used |
in my ASCII art, so it crashed, Dumb Dumb Dumb :)
This question is related to
batch-file
newline
echo "text to echo" > file.txt
copy con
to write text, It so easy to write a long textExample:
C:\COPY CON [drive:][path][File name]
.... Content
F6
1 file(s) is copied
Maybe this is what you want?
echo foo > test.txt
echo. >> test.txt
echo bar >> test.txt
results in the following within test.txt:
foo
bar
Use the following:
echo (text here) >> (name here).txt
Ex. echo my name is jeff >> test.txt
test.txt
my name is jeff
You can use it in a script too.
You can easily append to the end of a file, by using the redirection char twice (>>
).
This will copy source.txt
to destination.txt
, overwriting destination in the process:
type source.txt > destination.txt
This will copy source.txt
to destination.txt
, appending to destination in the process:
type source.txt >> destination.txt
Source: Stackoverflow.com