Skip to main content

How to create empty files from the command prompt (cmd): Well, sometimes you just need to create empty files in Windows for apps to work in a portable environment or to exploit null files in another procedure. Whatever the reason, knowing how to create empty files from the command prompt will only help you and help you better understand your system.

Now the PSIX compatible systems have a touch command that creates empty files but in Windows there is no such command so it is more important to learn how to create one. You must be thinking why not create an empty file from notepad and save it, well, it is not actually an empty file, this is why this task is done using the command prompt (cmd).

How to create empty files from command prompt (cmd)

1.Press Windows key + X and then select Command Prompt (Admin).

2. Type the following command and press Enter: cd «C: Your Directory« Note: Replace your directory with the current directory you need to work with.

3.To create an empty file, type this command and hit Enter: copy nul "emptyfile.txt" Note: Replace emptyfile.txt with the name of the file you need.

4.If the above command fails to create an empty file, try this one: copy / b NUL EmptyFile.txt

5.Now the problem with the previous command is that it will always show that the file was copied and to avoid this you can also try the following command: write NUL> 1.txt

6.If you really want a totally empty file, with no output to stdout then you can redirect stdout to nul: copy nul file.txt> nul

7.Another option is to run aaa> empty_file which will create a void in the current directory and then try to execute the aaa command which is not a valid command & thus create an empty file.

C: N-Aditya Users> cd Desktop C: N-Aditya Users N-Desktop> aaa> empty_file "aaa" is not recognized as an internal or external command, operable program or batch file. C: N-UsersAdityaN-Desktop> dir Aditya Desktop user directory. 06/09/2017 10:41. 06/09/2017 10:41 .. 06/09/2017 10:41 0 empty_file


8.Also, you could write your own touch command:

#include #include int main (int argc, char ** argv;) {yes (argc! = 2) {std :: cerr 7. Save the above file as touch.cpp and that's all you've created a touch program.

Recommended for you:

  • Fix the dns_probe_finished_bad_config error
  • How to fix application error 523
  • How to fix the 502 Bad Gateway error
  • Fix The app did not initialize correctly

You have already learned how to create empty files from the command prompt (cmd), but if you still have any questions about this guide, feel free to check it out in the comments section.