1.

Solve : Is it possible to write simple text files with batch??

Answer»

I know i can use the echo command to write something but that will enable me to write something with only one line, unless i use && or ^& but THATS only for if i'm WRITING ANOTHER batch file.

example code
Code: [Select]echo hello > hello.txt
My question is basically if i can write a file with multiple lines of text making it a simple text file?> overwrite file/create if not exist
>> append to filehttp://www.afunnystuff.com/forumpics/moresense.jpgCode: [Select]echo hello > hello.txt
echo hi >> hello.txt
echo does this work? >> hello.txtNotice the > in the first line and >> in all following lines.
The single > overwrites the previous contents of the file with what is before it.
Example:
echo The only line > file.ext

The double >> does NOT overwrite the previous contents of the file, but puts the text before it at the end of the file.
Example:
echo The last line > file.ext

Do you understand now?(
echo hello
echo world
)>a.txtQuote from: Prince_ on APRIL 19, 2009, 03:27:05 AM

(
echo hello
echo world
)>a.txt
that's the 4 line equivilent of what can be done in 2 (or 1).

echo hello > a.txt
echo world >> a.txt

or
echo hello > a.txt & echo world >> a.txtlike Helpmeh, you can move ">" to begin of your command.
> a.txt echo hello
>>a.txt echo world
>>a.txt echo does this work?

Quote from: tonlo on April 19, 2009, 08:49:06 AM
like Helpmeh, you can move ">" to begin of your command.
> a.txt echo hello
>>a.txt echo world
>>a.txt echo does this work?


I have never tried it that way...


Discussion

No Comment Found