Delete a file named NUL on Windows

Delete a file named NUL on Windows

August 6, 2019 Uncategorized 1

So…here we are. You were probably using stuff ported from a UNIX-like system and managed to create a file called NUL on a Windows system.

A file name that’s special on Windows and that can’t be deleted.

Well…this is awkward.

Fortunately, the solution is a command prompt command away. You’ll need to know the full path to the file. Open a command prompt (an elevated one if necessary) and instead of something like “del C:\Windows.old\Temp\NUL”, type this:

rename \\.\C:\Windows.old\Temp\NUL file.txt
del file.txt

 

NUL file is gone! That was easy.

 

One Response

  1. Les says:

    Yes…
    It worked couple of times – but the ghost in the machine got smarter.
    This does not work any more:
    D:\Analysis-PATRAN\TEST – Copy>rename \\.\D:\analysis-patran\test – copy\nul. deletefile.txt
    And yes – there are spaces in “test – copy”

    The error message is:
    “The syntax of the command is incorrect.”

    Any suggestions ?

    Regards
    Les

Leave a Reply

Your email address will not be published. Required fields are marked *