How to create empty text file from a batch file?

m_pGladiator picture m_pGladiator · Oct 16, 2008 · Viewed 558.6k times · Source

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

Answer

ephemient picture ephemient · Oct 17, 2008
copy NUL EmptyFile.txt

DOS has a few special files (devices, actually) that exist in every directory, NUL being the equivalent of UNIX's /dev/null: it's a magic file that's always empty and throws away anything you write to it. Here's a list of some others; CON is occasionally useful as well.

To avoid having any output at all, you can use

copy /y NUL EmptyFile.txt >NUL

/y prevents copy from asking a question you can't see when output goes to NUL.