Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

At first I'd like to say 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 other. As we all know, it does the following:

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?

like image 478
kefir500 Avatar asked Sep 25 '15 12:09

kefir500


2 Answers

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: http://blogs.msdn.com/b/oldnewthing/archive/2010/10/11/10073890.aspx

like image 139
Mark Segal Avatar answered Oct 19 '22 09:10

Mark Segal


You have to remember, DOS dates back to before we even had mice to cut and paste text and when screens were 80x25 text. Extra typing, particularly if you had to remember something and type it in later, was extremely painful. Now imagine trying to work on more than one drive. With only one current directory, you'd have to fully specify directories on drives other than the current drive. That would require writing down the paths on the other drives because they wouldn't stay on screen. Ouch.

So instead you could do:

dir a:           <- See what dir I need
cd a:foo         <- This one
dir a:           <- See what file
dir b:           <- See what dir I need
cd b:bar         <- This one
dir b:           <- See what file
a:program b:data <- use them both

Otherwise, it'd be:

dir a:                <- See what dir I need
cd a:foo              <- This one
dir a:                <- See what file (lots of scroll)
dir b:\               <- See what dir I need (scroll)
cd b:\bar             <- This one
dir b:                <- See what file (lots of scroll)
a:\foo\program b:data <- use them both (had to remember "foo")

Now imagine it's more than one directory deep.

And now, imagine if the program doesn't support subdirectories and you need to pass two paths to it on two different drives.

like image 25
David Schwartz Avatar answered Oct 19 '22 09:10

David Schwartz