Why is the DOS path character ""?

Many, many months ago, Declan Eardly asked why the \ character was chosen as the path separator.

The answer’s from before my time, but I do remember the original reasons.

It all stems from Microsoft’s relationship with IBM.  For DOS 1.0, DOS only supported floppy disks.

Many of the DOS utilities (except for command.com) were written by IBM, and they used the “/” character as the “switch” character for their utilities (the “switch” character is the character that’s used to distinguish command line switches – on *nix, it’s the “-” character, on most DEC operating systems (including VMS, the DECSystem-20 and DECSystem-10), it’s the “/” character” (note: I’m grey on whether the “/” character came from IBM or from Microsoft – several of the original MS-DOS developers were old-hand DEC-20 developers, so it’s possible that they carried it forward from their DEC background).

The fact that the “/” character conflicted with the path character of another relatively popular operating system wasn’t particularly relevant to the original developers – after all, DOS didn’t support directories, just files in a single root directory.

Then along came DOS 2.0.  DOS 2.0 was tied to the PC/XT, whose major feature was a 10M hard disk.  IBM asked the Microsoft to add support for hard disks, and the MS-DOS developers took this as an opportunity to add support for modern file APIs – they added a whole series of handle based APIs to the system (DOS 1.0 relied on an application controlled structure called an FCB).  They also had to add support for hierarchical paths.

Now historically there have been a number of different mechanisms for providing hierarchical paths.  The DecSystem-20, for example represented directories as: “<volume>:”<“<Directory>[.<Subdirectory>”>”FileName.Extension[,Version]” (“PS:<SYSTEM>MONITR.EXE,4″).   VMS used a similar naming scheme, but instead of < and > characters it used [ and ] (and VMS used “;” to differentiate between versions of files).  *nix defines hierarchical paths with a simple hierarchy rooted at “/” – in *nix’s naming hierarchy, there’s no way of differentiating between files and directories, etc (this isn’t bad, btw, it just is).

For MS-DOS 2.0, the designers of DOS chose a hybrid version – they already had support for drive letters from DOS 1.0, so they needed to continue using that.  And they chose to use the *nix style method of specifying a hierarchy – instead of calling the directory out in the filename (like VMS and the DEC-20), they simply made the directory and filename indistinguishable parts of the path.

But there was a problem.  They couldn’t use the *nix form of path separator of “/”, because the “/” was being used for the switch character.

So what were they to do?  They could have used the “.” character like the DEC machines, but the “.” character was being used to differentiate between file and extension.  So they chose the next best thing – the “\” character, which was visually similar to the “/” character.

And that’s how the “\” character was chosen.

Here’s a little known secret about MS-DOS.  The DOS developers weren’t particularly happy about this state of affairs – heck, they all used Xenix machines for email and stuff, so they were familiar with the *nix command semantics.  So they coded the OS to accept either “/” or “\” character as the path character (this continues today, btw – try typing “notepad c:/boot.ini”  on an XP machine (if you’re an admin)).  And they went one step further.  They added an undocumented system call to change the switch character.  And updated the utilities to respect this flag.

And then they went and finished out the scenario:  They added a config.sys option, SWITCHAR= that would let you set the switch character to “-“.

Which flipped MS-DOS into a *nix style system where command lines used “-switch”, and paths were / delimited.

I don’t know the fate of the switchar API, it’s been long gone for many years now.


So that’s why the path character is “\”.  It’s because “/” was taken.

Edit: Fixed title – it’s been bugging me all week.


Comments (54)

  1. vince says:

    For a similar article see entry III.15 in this http://netwhatever.com/faq/inicio.html

    Also to note, / was a common command-line-option indicator in CP/M, and QDOS (which Dos1 was of course based off of) was very much a clone of CP/M.

  2. Travis Owens says:

    Interesting, I had always wondered why DOS used something different wen UNIX was well established and accepted standard and I sometimes wondered if it was different just for the sake of being different.

    Glad to see that assumption was wrong.

  3. Maurits says:


    Not laughing at your post. Just the munging of the title.

    I put in a bug report to the blogs.msdn.com complaining that the HtmlEncoding was messed up, pointing them to the Date&Time munging as an example. Then they sent me an email back that they’d fixed it, and sure enough, your Date&Time title was fixed – it wasn’t Date&amp;Time anymore.

    It appears they just hacked up a Replace(overlyescapedtitle, "&amp;", "&") line instead of finding and removing the extra HtmlEncode.


    I laugh so I will not cry…

  4. Andreas Haeber says:

    Just wondering about a little detail here:

    "For MS-DOS 2.0, the designers of DOS chose a hybrid version – they already had support for drive letters from DOS 1.0, so they needed to continue using that."

    Where did the drive letters come from, then? I really hate them :) Happily I can, and do, use junctions points now, but you still need to have at least one left. It’s so much cleaner with the unified filesystem :) And it is easier to discover special files like the CON, NUL, LPT devices when you can just do

    dir /devices or something like that.

  5. Fox Cutter says:

    Drive letters came about (at least to my understanding) because the first PCs supported two disk drives.

    At the time assigning them letters solved the problem of how to access them. A: for the first drive, B: for the second. When the Hard drive came out it was given drive letter C: because it was the next in line.

  6. Jerry Pisk says:

    I don’t understand why the switch/parameter character cannot be present in paths. Unix has no problems working with paths that have – in them, most systems, including Windows, can handle paths with spaces in them even though spaces are used to separate arguments and so on.

  7. LarryOsterman says:

    Andreas: *nix commands have no problems with files with "-" in the name?

    How do you remove the file named "-r"?

  8. vince says:

    > Where did the drive letters come from, then?

    Why CP/M of course, which QDOS (and hence DOS 1) was a clone of. Read the first chapter of http://www.iso.port.ac.uk/~mike/interests/chistory/documents/cpm-22-manual/ here to see where DOS’s real heritage lies…

  9. vince says:

    > How do you remove the file named "-r"?

    With "rm — -r" of course. There’s actually quite a few ways to do this.

  10. LarryOsterman says:

    And where did CPM get them from? The DEC operating systems I mentioned above.

    That’s also where the copy command and a number of the other command line features of CPM came from.

  11. Ben Cooke says:

    I wish it was possible to have a directory junction pointing at a drive letter for a mounted UNC path. That’s the only thing that escapes my amazing single filesystem: I have some stuff that lives on another computer, and there’s no way to map L:My Documents to C:My Documents were L: is a mounted path. It works fine otherwise.

    Why is this the case anyway? Why are mounted UNC paths any different?

  12. TheMuuj says:

    I’m way too young know this first-hand, so I’ll ask.

    Why is there a "" key on the keyboard in the first place? As far as I know, they aren’t used in English grammar, and to this day, most common users don’t know which is "back" and which is "forward."

    I suppose I can ask the same about "{" and "}", but I don’t mind those as much.

    Since DOS and Windows handle "/" as well as "", it’d be nice if it would switch to using "/" by default, since Internet URLs use forward slashes, and most people are familiar with them (even though browsers/web servers have to support "" as well, because of the problem I mentioned earlier, which ultimately lead to security bugs in server-side web software).

    I can’t imagine switching to "/" would hurt much backwards compatability, since most path paramters have to be put in quotes these days (thanks to the needlessly long "Document and Settings" and "Program Files").

    I too would like to get rid of drive letters. I’m consdering mounting my all-in-one memory-card reader onto a folder on my hard drive because I’m tired of having C:, D:, E:, F:, G:, H:, I:, J: all show up under My Computer (and X:, Y:, and Z:, but that was my doing). If I mount everything, I can pretend that C: stands for "Computer," but I suspect mounting CD-ROMs causes problems for some pesky copy-protected games (which are another pet peeve of mine).

    I was hoping Monad would help reduce the visibility of drive letters, but I was wrong. It doesn’t even support changing the current path to a UNC share, which is a HUGE limitation of both CMD.EXE and any future shells.

  13. vince says:

    > Why is there a "" key on the keyboard in the first place? As far as I know, they aren’t used in English grammar, and to this day, most common users don’t know which is "back" and which is "forward."

    The backslash was invented by Bob Bemer http://www.thocp.net/biographies/bemer_bob.htm

    It’s use was so you could make the / and / symbols (AND and OR if you’ve ever done boolean logic) in the ALGOL language.

  14. vince says:

    And of course I meant "its" not "it’s". As is oft requested, I wish the msdn blogs had a preview button.

  15. vince says:

    > And where did CPM get them from? The DEC operating systems I mentioned above.

    I thought the question was about drive letters specifically.

    An RSX-11 file path looks like DR0:[30,12]FILE.TXT;10

    A CP/M file path for a file on the first floppy looks like


    Tim Patterson who wrote QDOS (the basis for DOS 1) did it based on a CP/M manual. I’ve never heard it mentioned that he spent any time on any DEC machines.

    There’s nothing wrong with DOS originally being a clone of CP/M (similar to how Linux started out as a clone of U*IX), I just think people often gloss over the history.

    My favorite Gary Kildall quote on the issue:

    "Ask Bill [Gates] why the string in function 9 is terminated by a dollar sign. Ask him, because he can’t answer, only I know that."

  16. Hans Spiller says:

    several more tidbits to this story:

    IBM made us chose a path separator that was unshifted on the original PC keyboard. Tim and Z and friends chose "" because most of the other unshifted characters already had meaning to command.com. there was lots of discussion at the time about ":" for example, which was used in some other heirarchical file systems. it’s the drive separator but not hard to disambiguate. IBM nixed it because it requires a shift key to type.

    the mechanism that became "SWITCHAR" was originally put in because they wanted to prove that it would be easy to disambiguate the path separation function from the command line switch function. this was entirely correct and nearly all command line apps support both "-" and "/" seamlessly. but IBM refused to buy it.

    Much effort was made to keep the fact that SWITCHAR was in shipping systems a secret because it was suspected that when IBM found out they would make us take it out. this suspicion was proven correct. It took them almost 5 years to find it though, and none of the original DOS crew was still working on it. Eric made the change, as I recall.

    the Tops-10 ==> CP/M ==> DOS genealogy someone else mentioned is correct. Tops-20 was very late in the story and not really relevant.

  17. Declan Eardly says:

    Crikey – I’d almost forgotten I’d asked that … 8)

    many thanks for the explanation – this was one of those little things that I have wondered about every now and then – and it is very nice to have an answer (and a pretty comprehensive one to boot).

    This has made my day!

    Declan Eardly

  18. Thomas Hill says:

    Another ‘undocumented feature’ in MS-DOS that I used a lot was that the API calls that used drive letters did not validate the character for a drive letter – this let you use things like "#:/HIDDEN" and get away with it…although I am now hazy about what actually happened, I remember that I used it several times.

  19. spork says:

    I used CP/M as a young punk, then VMS in college, and DOS later in college. I found my user experience to be fairly consistent across all of these. (I still have trouble with VMS directories, I must admit.)

  20. John Elliott says:

    I remember being very annoyed when I went from using Visual C++ 1.52 to a 5.0 (both on Windows NT 4). 1.52, being 16-bit, used the 16-bit file dialogs, which could grok a typed path containing forward slashes. 5.0 used Explorer file dialogs which couldn’t (I don’t know if this has been fixed in later Windowses).

    Do we get a matching retrospective on the function that moved all the special files into DEV (sorry, /DEV)?

  21. Rune says:

    "It doesn’t even support changing the current path to a UNC share, which is a HUGE limitation of both CMD.EXE and any future shells."

    4NT (from http://jpsoft.com/) supports CD to a UNC path. Just type CDD \myservermyshare and there you are… At the root of a share! :)

    (I even suspect it was I who suggested this to JPSoft many years ago)


  22. Maurits says:

    HtmlEncoding fixed? Looks OK in the comment posting form… let’s see how it looks once it’s posted…

  23. Shekhar Joshi says:

    This is interesting bit of information.

  24. Ancient History: The origins of ”

  25. meneame.net says:

    Explicación (en ingles) de por qué se elegió el caracter (backslash) como el separador de ruta para Windows.

  26. Larry Osterman tells the entire story: simply because slashes were already used for parameters before DOS even knew what a path or a directory is. Nice read and a trip down memory lane.

  27. submitted by scientologist2 to programming [link] [368 comments]