Search code examples
windowscommand-linecmdcommand-promptcd

What is the reason for the CD /D switch in Windows cmd?


First I would like to note that I do understand the purpose of the /D switch for the Windows Command Prompt cd command. I'm just curious why it works this way and not otherwise. As we know from the help:

Use the /D switch to change current drive in addition to changing current directory for a drive.

But every single time I enter (for example) cd F:, it's obvious enough that I would like to change the drive. That is why I think this switch is redundant by itself.

So what's the point of explicitly setting this switch? Why it isn't implied by default?


Solution

  • Short answer: Because DOS behaved this way, and cmd tries to mimic DOS.

    Originally, DOS had a 'current director' for each drive, so if you write cd d:\folder you change the current directory for the D drive.

    You can read more about this here: https://devblogs.microsoft.com/oldnewthing/20101011-00/?p=12563