TL;DR – If you end up with an invalid filename on Windows, you can manipulate the file using the secret DOS name.
There’s a folder on my Windows 7 machine that I can’t delete! It’s called
Goldberg Variations BWV 988 and was created when I backed up a CD with Media Player.
Why can’t it be deleted? Doing so gives an error saying it doesn’t exist:
And yet there it is. Does it have any funny permissions? Nope. In fact it doesn’t seem to have any permissions at all:
Hrm. Is it corrupted? Chkdsk doesn’t seem to think so.
Let’s try deleting it from the command prompt:
E:\incoming\Bach>dir Volume in drive E is enormous Volume Serial Number is 7081-2770 Directory of E:\incoming\Bach 05/07/2012 08:23 p.m. <DIR> . 05/07/2012 08:23 p.m. <DIR> .. 16/01/2012 01:07 p.m. <DIR> Goldberg Variations BWV 988 E:\incoming\Bach>rmdr "Goldberg Variations BWV 988 " The system cannot find the file specified.
Um, what’s that space doing there? (I tab-completed the name.) Let’s try a few tricks:
E:\incoming\Bach>rmdir "Goldberg Variations BWV 988?" The filename, directory name, or volume label syntax is incorrect. E:\incoming\Bach>rmdir "Goldberg Variations BWV 988*" The filename, directory name, or volume label syntax is incorrect.
Nope. Windows Media Player has somehow created a file with a name that isn’t valid, and hence can’t be removed by anything.
But wait, ancient lore from the 90s might have something to say. Being the layer-upon-crufty-layer of bloatware that it is, Windows contains a lot of legacy functionality. Including full “support” for the fixed 11 character filenames of DOS. Almost every single file on a modern Winodws 7 NTFS drive from 2012 has a secret DOS name, too. Just in case an app written in 1983 wants to open it.
The DOS names are not hard links. They are alternative names for the real links. (So if you create a hardlink, you get a DOS name for the new hardlink, too.) They are created, by default, on NTFS volumes for files whose real names do not fit within the original 8.3 DOS scheme.
E:\incoming\Bach>dir/? Displays a list of files and subdirectories in a directory. ... /X This displays the short names generated for non-8dot3 file names. The format is that of /N with the short name inserted before the long name. If no short name is present, blanks are displayed in its place. ... E:\incoming\Bach>dir /x 16/01/2012 01:07 p.m. <DIR> GOLDBE~1 Goldberg Variations BWV 988
GOLDBE~1, eh? I would never have guessed.
E:\incoming\Bach>dir /x Volume in drive E is enormous Volume Serial Number is 7081-2770 Directory of E:\incoming\Bach 06/07/2012 10:00 p.m. <DIR> . 06/07/2012 10:00 p.m. <DIR> .. 0 File(s) 0 bytes 2 Dir(s) 151,020,306,432 bytes free
Gone. Some of that bloaty legacy code is useful, after all.