MS-DOS also allowed spaces in file names, although vanishingly few programs knew how to access them


A little-known fact about MS-DOS is that it allowed spaces in file names. Sure, you were limited to 8.3, but a file called "LOOK AT.ME" was legal in MS-DOS, and you could indeed create such a file. Good luck finding programs that didn't treat you as insane when you asked for that file, though.

Although the file system supported files with spaces, practically no programs supported them. Command line tools saw the space as the end of the file name. You couldn't quote the file name because no command line tool supported quotation marks to protect spaces. After all, if you believed that spaces were illegal characters in file names, you wouldn't write extra code to allow people to specify a file name with spaces in them!

The only program in common use that I remember supporting spaces in file names was GW-BASIC. If you were naive enough to create a file in GW-BASIC with a space in its name, you found yourself in a pretty nasty world of hurt once you escaped GW-BASIC back to the real world. The easiest way to delete such a file was to go back into GW-BASIC and delete it from there.

Comments (30)
  1. Alexandre Grigoriev says:

    In NT-based OS you can create an "undeletable" and "unaccessible" (for most programs) file by using filename format that bypasses Win32 prettification. It also bypasses legacy reserved name handling (COM1, LPT, etc).

    Prepend \? to the full pathname (I think it also bypasses partial->full pathname conversion), and voila.

    Win32 removes a period at the end of filename before passing it to the kernel. But if the filename starts with \?, the period is not removed. Thus, you can create a file or directory with a name that ends with ‘.’, and most programs (including Explorer) won’t be able to do anything with it. You can’t see contents of such directory in Explorer.

  2. Jerry says:

    That’s because the filename was padded with spaces up to 8.3, so it had to be valid in filenames.

    Having a file LOOK.ME, REN LOOK.ME ?????AT.ME would replace the name with LOOK AT.ME, including a space on fifth position, because the space was already there.

    To delete it, the same rename trick could be used to replace the space with something else.

  3. Bob says:

    I accidentally created a file like that using the original SimCity. Deleting it was fun.

  4. Aaargh! says:

    Another option in *nix (Don’t know if this is a GNU specific thing) is to add — -rf it will stop processing command line arguments when it encounters a double –

  5. Random832 says:

    That’s a standard unix thing, in so far as it is specified in POSIX. YMMV on older versions though.

    (It goes without saying that neither of those will prevent glob expressions like * from being processed)

  6. J says:

    I was proficient in DOS but no expert, and so I still remember the triumphant moment when I finally stumbled upon the docs that told me about the ‘?’ wildcard that I could use to delete files with characters I couldn’t type for the del command.

    Related to the other post today, I could imagine someone saying in response, "Well why didn’t you just search the internet to figure out how?"

  7. Someone You Know says:

    @Alexandre Grigoriev

    So how would you manipulate such a folder/file? Or would it just be doomed to sit there untouched until the drive is formatted?

  8. ton says:

    @Someone You Know

    I can’t speak for Alexandre but in my opinion it’s not meant for anyone to manipulate such a folder/file it’s really meant for whoever created it to cloak or hide the presence of certain files on an unsuspecting users PC. If a custom utility is written though this can be circumvented but its not likely that an average everyday user will now to look for it or how to remove it.

  9. MadQ says:

    @Alexandre Grigoriev: It’s even more fun to throw in a circumflex (or hat, if you prefer): \?C:^^.

    The file name will be just the last two characters of the above.

    I don’t think it’s widely known that ^ is an escape character, so you do things like ECHO 2^>1 without actually redirecting.

  10. JenK says:

    The MS-DOS Shell also renaming and using files with spaces in them.  

    In other news, there was this "MS-DOS Shell" thing… ;)

  11. Torkell says:

    IIRC, OS/2 used a space in the name of the extended attributes file on FAT filesystems. I think it was something like "EA DATA. SF". It got rather annoying when you had a floppy disk with that file on it, and couldn’t easily delete it to free up space.

  12. HA HA HA says:

    I remember including the BEL character (Ctrl+G) in file names on the Apple II 25ish years ago. Great fun.

  13. Evgeny says:

    As I recall file managers like Norton Commander were working fine with almost any file names.

  14. Alexandre Grigoriev says:

    @Someone You Know

    del \?c:pathfilename.

    or

    rmdir \?c:path.

    One time, I’ve got one such file in IE temporary files folder.

    Oh, and it also allows to use really long paths which Windows Explorer can’t handle.

  15. Tom says:

    Well that *is* odd.  I used to create "undeletable" files by using the special hold-down-alt-and-type-ASCII-code-on-keypad method of putting space-like characters (if memory serves, ASCII 255) into filenames, but I never thought of actually using a space.  I guess I just assumed that spaces were illegal in filenames.  Of course, even though spaces are legal, because most programs wouldn’t work right with those names, it might as well have been illegal to have spaces in names.

  16. William C Bonner says:

    The thing that was interesting about the way that MSDOS actually stored the filename was that there was no period stored.  It just stored the string as a set of 11 characters.  

    If you used a sector editor to manipulate the FAT you could store the names you liked with lower (or mixed) case letters, even though the command line tools all converted the text to upper case before saving it.

  17. Anonymous says:

    In Unix you can create a file called "*".  Then watch someone try to delete it with "rm *".  (Put the star in quotes or escape it with and you’re OK…)

    It’s also fun to create a file called "-rf".  You can get rid of that one with "rm ./-rf"

  18. Steve D says:

    I can remember naming files or even directories as ALT+255.  It worked well until Norton Commander and Xtree became popular…the whole notion of selecting from a list is deeply flawed! :-P

  19. jondr says:

    I remember (in DOS days) people at work somehow creating files with weird characters in the name and being unable to delete them. The trick we used was to get into the GW-BASIC environment which gladly handled the oddball names and allowed you to kill them.

  20. Miral says:

    I too remember ALT+255 in filenames with fondness :)

    And I ran across spaces being permitted a few times as well.  Don’t think I ever actually used that for obfuscation, though.

  21. Anonymous Coward says:

    Well, maybe it was the software I was using, but I remember games that allowed spaces in their save files, the various programs above mentioned, a drawing program (can’t remember which, only that it was obscure). I think that the programs that didn’t swallow the space were mainly those that parsed the file name in some manner, like command line utilities.

  22. mos says:

    I remember running across this in the game Earl Weaver Baseball (my 10-year-old self is clamoring for me to find an emulator, now).  This was awhile ago, but I think I remember the game letting me save games with a space in the name, but not load it.  Or maybe it did let me load it, but I recognized that DOS didn’t normally support spaces in the filename.

    Great game, though.

  23. mos says:

    Ah, yes.  Alt-255.  We used those to "hide" networked computer games on the university’s lab computers.  Great times.

  24. JenK says:

    Oh MY that was garbled.  *rolls eyes*  Obviously the mental and emotional toll of working on DOS has completely destroyed my mind.  ;)

  25. BCS says:

    I once ended up with a file with *box drawing chars* in it. Yuck

  26. MadQ says:

    Speaking of Alt-255… I got stuck with a lame old 286 once while everyone else was getting those new-fangled 386s, so I sabotaged my own PC by creating an executable (using ye goode olde DEBUG in MS-DOS) called ECHO<Alt-255>ON.COM and made it a hidden file. At the end of the AUTOEXEC.BAT I added a seemingly useless statement that looked like ECHO ON.

    The program just changed the RAM refresh rate so that I’d get parity errors at least every few hours. After a few days of this, even with newly installed SIMMs, tech support finally gave up and I got a brand-spanking new IBM PS/2. Beta-testing MS-DOS 5.0 was much more fun on the 386.

  27. John Elliott says:

    CP/M had something similar. Not only did it allow spaces in filenames, it allowed lower-case letters. And Microsoft BASIC didn’t force filenames into uppercase, whereas just about every other program, including all the command-line tools, did.

  28. I used to make ALT+255 (yes, it looks like a space) in filenames too, as well as using GW-BASIC to make spaces in filenames.  GW-BASIC used to BE my OS, so I didn’t know I was doing anything ‘wrong’ until I got used to actually using DOS as something other than a GW-BASIC launcher.

    I later figured that GW-BASIC was just accessing the interrupt in a way that DOS and others would not allow — merely since you needed to use quotes to specify strings, and the string could contain anything, including spaces, which was passed directly to the interrupt.

    I later thought it could be used as a nice (lol) way to regulate installation and copy protection, forcing the user to use your own installation and uninstall, rather than allowing users to merely copy files onto a disk for their friends.  Imagine that — software that you couldn’t uninstall without it’s own software, lol.  I was young and was thinking about it from a programming perspective, not a user friendly perspective. :P

  29. fat space says:

    fat file names almost always has space in them, because 11 characters are always stored is the file system. file names are space padded.

  30. The Imp says:

    I do remember that EDIT could open files with space or other unusual characters (at least some versions could), though edit could not delete any file, and I’m not sure if it could save files with a new name that included a space.

    Also, PKUNZIP would happily create files with spaces or other unusual characters upon deflation, if that is what they were named inside the zip. This caused a fair amount of aggravation when using old DOS copies of PKUNZIP once Windows 95 rolled around and people started sending you zipped files.

    There could very well have been more, but my memory of those dark times is thankfully not very complete :-)

Comments are closed.