How to overwrite a text file from a batch file

James picture James · May 16, 2013 · Viewed 23.8k times · Source

I am aware you can append to the end of a file with batch like so...

echo I like turtles >> file.txt

but I would like to overwrite the file instead. How could this be done?

Answer

James picture James · May 16, 2013

Just answered my own question, this works:

echo I like turtles > file.txt

                    ^
                    |
            Just one of these