How to create an empty file at the DOS/Windows command-line?
I tried:
copy nul > file.txt
but it always displays that a file was copied.
Is there any other method in the standard cmd?
It should be a method that does not require the touch command from Cygwin or any other nonstandard commands. The command needs to run from a script so keystrokes cannot be used.
worked when creating a file in C:/Program Files where you don't have the access to create files directly.
You can use the old command
don't type anything, just press F6 to save it, however it will print "File copied", but when you open the file, it will be empty
Open file :
New file :
Edit content:
Copy
Rename
Delete file :
echo.
suppress the "Command ECHO activated"|set /p=
prevent newline (and file is now 0 byte)Try this:
this will definitely create an empty file.
If you really want a totally empty file, without any output to stdout, you can cheat a little:
Just redirect stdout to nul, and the output from copy disappears.