Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete content from a text file using windows batch script

Tags:

batch-file

I have a demo.txt file. I need to delete content in that file using a batch file. Please tell me the command to delete content for demo.txt file.

like image 661
user2918831 Avatar asked Oct 28 '13 11:10

user2918831


People also ask

What is @echo off in batch script?

batch-file Echo @Echo off @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.

How do I delete a text file in CMD?

To delete a file, use the following command: del "<filename>" . For example, to delete Test file. txt , just run del "Test File. txt" .


1 Answers

break>demo.txt 

Try this.it will set an empty file on the place of demo.txt. As break is internal command that does nothing it should be pretty fast.Also the break command can produce output only with /? argument so this makes this method pretty robust.

like image 162
npocmaka Avatar answered Sep 28 '22 22:09

npocmaka