Delete undeletable files from NTFS file system

Date posted: 2010-01-12
Last updated: 2026-10-03

"The filename, directory name, or volume label syntax is incorrect"? Here's how to delete such files using the \\?\ prefix in Windows.

Sometimes you cannot delete files on an NTFS file system, for example if the file name contains a space at the beginning or end, or is a reserved name. Deleting the file gives an error: "The filename, directory name, or volume label syntax is incorrect.". Here's how to fix it: use "internal" commands.

Files with a reserved name like con.gif, or with a trailing space, can't be deleted the normal way in Windows. Prefix the full path with \\?\ in cmd.exe, for example del "\\?\C:\path\to\file.ext ", to bypass the Win32 file name checks.

The error in English and Dutch:

E:\Users\foobar>del "con.gif"
The filename, directory name, or volume label syntax is incorrect.

E:\Users\foobar>del "con.gif"
De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist.

Another error message that often appears is: "The system cannot find the file specified.".

Remove undeletable files by using internal commands

You can delete files with a reserved name (all names are listed below) using an internal command. This bypasses the check for reserved file names in the Win32 name space. To do this you have to work from the Windows command prompt (cmd.exe), which you preferably start with administrative rights.

A number of examples:

E:\Users\foobar>del \\?\c:\Users\foobar\con.gif
cd /d E:\Users\foobar\map1\map2\(....)\mapx
del \\?\%CD%\con.gif
del \\?\%CD%\lpt1.gif

In the case of files with spaces, you must use double quotes:

del "\\?\C:\path\to\corrupt\file.ext "

Or you can rename a file first:

C:\> rename \\.\C:\CON. deleteme
C:\> del deleteme

Reserved filenames on NTFS

Reserved file names on the NTFS file system are:

  • CON, PRN, AUX and NUL
  • COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8 and COM9
  • LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8 and LPT9

You can still delete these files by means of the above internal commands. See Microsoft's Naming Files, Paths, and Namespaces documentation for more information.

Running into "path too long" errors instead? Enable NTFS long paths through GPO in Windows Server.

I write these posts in my spare time, based on real problems from my day job as a sysadmin. If this one saved you some debugging time, a small donation is much appreciated. Thanks! 🙏

Leave a Comment