Delete Contents of Txt File

I would like to delete the contents of a text every day;  instead of deleting the actual file.

What is the best way to do this?
Nick CollinsAsked:
Who is Participating?
Omar SoudaniSystem Support EngineerCommented:
You can create a batch file and it will delete the content of the text when you run it.

Open notepad:
@echo off
break> c:\"Your file directory"\yourfilename.txt

Save as: choose and name and put .bat at the end

Everytime you double click on that batch it will delete the content of "yourfilename.txt"
David GipeCommented:
You can also use the command "type > c:\"Your file directory"\yourfilename.txt". Basically, any command which fails to execute (without an error message) can be used before the ">" to create a zero byte file.

Also, you can use Omar's BAT file as a scheduled task to run every day at the same time, so you don't have to do it manually.

On a side note, if you need a folder on your C-drive to store your BAT's, the best folder name I have ever seen is "Belfry" ... store your BATs in the Belfry.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.