This question is not the same as How to delete an invincible 0 byte file? since none of the answers have worked and my impossible to delete file I "feeeel" is different.

I was following this website to delete a folder with a node_modules folder. These take forever to delete using the File Explorer, and I can never remember the exact command to run every time. So I looked it up.


I use the following command or my fudgy fingers and terrible eyes processed what I thought was: DEL /F/Q/S *.* > NUL

This deleted all of the files in the folder, but created this NUL file with 0 bytes. This tells me I messed up the command and something was piped to NUL when the link says > NUL is suppose to disable console output.

I've tried File Commander, del *., del *.*, dir /x doesn't show anything different from dir, the delete button in the file explorer, specifying all permissions on the file and trying everything again. Doesn't work.

I tried piping text into it hoping life could get easier if it had something in it. This didn't pipe any text into the file: echo "Hello world" > NUL

Being a programmer, I thought I could go deeper and write a c program to delete it. Nope. Didn't work.

       if(remove("C:/../../NUL") == 0)
          printf("Deleted successfully");
          printf("Unable to delete the file");

I tried writing text to the file in C and that also failed. Then I tried reading from it and writing the buffer stream to a new file.

       FILE *fp;
       FILE *fp2;
       char buff[255];
       fp = fopen("C:/../../NUL", "r");
       fp2 = fopen("C:/../../cmd.txt", "w");
       fgets(buff, 255, (FILE*)fp);
       fputs(buff, fp2);

I found two characters are in it. þa. No idea what "þa" represents. When I print the characters out to the console in Eclipse there's three of them and they are " aw". The first character is a blocked question mark. It's a little different looking from the Unicode replacement character. So now I'm here and left will a Scooby Doo mystery of these mysterious characters, a fudged command that created these characters, and a file that's unable to be deleted.

For some reason the first character in the string isn't saving so I grabbed some snippets from the Eclipse console output and for some reason Chrome also rendered it differently so I snagged a picture from there too. https://ibb.co/yQSfD8b

--UPDATE-- I ran the command DEL /f/q/s . > NULL. Running the flags with lowercase values are what messed me up.

  • You found that two characters were in your buff variable. That's not the same as having two characters come from the file.
    – Ben Voigt
    Commented May 5, 2021 at 19:53
  • I concur, CLEAR your buff before you start using it. fread() would probably be more appropriate since you don't know what is actually in there. Commented May 6, 2021 at 2:13
  • Clearing your buffer before writing to it sounds like a lesson a professor told us that didn't make any sense. Like buying a new car and checking for dead bodies right you purchase it.
    – Luminous
    Commented May 6, 2021 at 13:09

1 Answer 1


This question has already been answered on stackoverflow here.

A shameless copy/paste in case that link should ever die:

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

C:\> rename \\.\C:\..\NUL. deletefile.txt
C:\> 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.

  • I wonder what's the role of the trailing dot...also that of ..\
    – Tom Yan
    Commented May 6, 2021 at 8:56
  • As far as i know, its part of the filename here. Normally trailing dots are removed for FAT an HPFS filesystem compatibility, however NTFS is posix-compatible, so it supports it. By using \\.\ or \\?\ you disable the standard file normalization. I think the .. is there because its part of the fully qualified path name of NUL and doesnt function as a relative path specifier.
    – Silbee
    Commented May 6, 2021 at 9:20
  • It is however interesting how the NUL file did get created at all? Shouldn't Windows treat the NUL filename as special and when output is redirected to NUL, just redirect it to the null device (and not create a file named NUL), which is what the OP wanted all along?
    – raj
    Commented May 6, 2021 at 10:41
  • Awesome answer! I always find my questions either too vague and specific for anyone to answer, or they already have one. Another case of the latter.
    – Luminous
    Commented May 6, 2021 at 13:04
  • @Raj, i think they may have typed NUL. instead of NUL when executing the DEL command.
    – Silbee
    Commented May 7, 2021 at 8:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .