Delete a file named "NUL" on Windows Delete a file named "NUL" on Windows windows windows

Delete a file named "NUL" on Windows


Open a command prompt and use these commands to first rename and then delete the NUL file:

C:\> rename \\.\C:\..\NUL. deletefile.txtC:\> del deletefile.txt

Using the \\.\ prefix tells the high-level file I/O functions to pass the filename unparsed to the device driver - this way you can access otherwise invalid names.

Read this article about valid file / path names in Windows and the various reserved names.


If you have Git for Windows Installed (v2.18) do the following

  1. Open the directory containing the files you want to remove
  2. Left Click and select Git Bash Here
  3. Type rm nul.json at the command prompt and hit ENTER, the file now should be removed.

run Git Bash Here

NOTE: These screenshots show the removal of file nul.topo.json which is another file that I could not removed with a simple delete.

after command execution


I had a similar issue. It was probably caused by Cygwin as well (since I use this regularly), but I've since forgotten exactly how the file was created.

I also had trouble deleting it. I followed the advice of some other posts and tried booting into safe mode to delete the file, though this did nothing. The tip from +xxbbcc didn't work for me either.

However, I was able to delete the file using the Cygwin terminal! Cygwin createth and Cygwin destroyeth.