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?
This setting may be overridden with /-Y on the command line. The default is to prompt on overwrites unless COPY command is being executed from within a batch script. To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).
Short answer: yes, batch files can modify themselves whilst running.
Just answered my own question, this works:
echo I like turtles > file.txt ^ | Just one of these
You can use > instead of >> : this will overwrite the file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With