I have a Windows XP box (NTFS filesystem) on which I found a file named
NUL. I have not been able to remove this file in any usual way. The file appears to be owned by
Administrator in the
SYSTEM group, unlike any other file in the same directory (the other files are owned by my user id).
How do I get rid of this file? Where did it come from?
in the command prompt.
See this Microsoft Support article for details: You cannot delete a file or a folder on an NTFS file system volume, under “Cause 5: The file name includes a reserved name in the Win32 name space”.
Alternatively if you have Cygwin installed, you may want to know, that it has no problem with such files or folders. Particularly,
rm -r /cygdrive/c/path/to/the/file/or/folder/you/want/to/delete
typed in the Cygwin terminal deletes the file or folder named
nul or a folder, containing it. This is also applicable to other special file names such as
I’m adding this here because it is high in the google results and I had a similar issue for a folder named NUL. Unfortunately the above fixes didnt help. Neither did a ton of other stuff I looked at.
rmdir\.C:MyPathNUL without any success and also tried several commands using bash from my SourceTree installation. No joy.
In the end I used
DIR /X /A from cmd to list the short names in the parent directory. This returned
NUL~1 for my NUL folder.
This was then used in the standard command
rmdir /s NUL~1 and finally fixed the problem.
If you have Git for Windows Installed do the following
- Open the directory containing the files you want to remove
- Left Click and select
Git Bash Here
rm nul.jsonat the command prompt and hit ENTER, the file now should be removed.
NOTE: These screenshots show the removal of file
nul.topo.json which is another file that I could not removed with a simple delete.