Search code examples
batch-filecmddos

How to create empty text file from a batch file?


Can somebody remember what was the command to create an empty file in MSDOS using BAT file?


Solution

  • echo. 2>EmptyFile.txt
    

    This redirects output stream 2 (stderr) to a file. The command echo doesn't output anything to stderr, so the file becomes empty.

    Plain echo would work too, but echo. is better because it doesn't print the useless and potentially confusing message ECHO is on.