12

Possible Duplicate:
Using cd Command in Windows Command Line, Can’t Navigate to D:\

Why, just why, is cd in Windows so stupid and does not do what it's supposed to do in the situations like this:

I:\Documents and Settings\blah\>cd C:\somedir\
I:\Documents and Settings\blah\>

I know you can chdir /d. But why is that not the default behavior?

houbysoft
  • 4,444

4 Answers4

22

This is by design. Each "drive" has it's own working directory. You can use chdir, or you can simply type the drive letter:

> D:

And that will change to the D drive. If you want to know why this behavior exists, see Raymond Chen's Explanation

vcsjones
  • 2,563
12

In windows could use the native cd/d <drive>:<path> or else chdir/d or pushd. It is the /d option that indicates that the drive should change as well. The pushd command does this by default.

Can even alias cd to make that the default behavior like so:

doskey cd=chdir/d $*

Then can use do things like:

cd D:\Temp
cd C:\WINDOWS

and the drive will change as well.

See the help by entering cd/? for more details.

2

It's a historical thing. cd only changes current directory on the drive that is specified (current if none), and <drive>: changes drives to the folder on that drive which was cd'd earlier (\ if none)

Hello71
  • 8,673
  • 5
  • 42
  • 45
1

some 3rd party shells - like 4dos has CDD command for this

You can create a batch file called "cdd.bat" in your main Windows directory with the following line:

@cd /d %1 %2 %3 %4 %5 %6 %7 %8 %9

Now, you can do the following with the new CDD command:

C:>cdd d:

D:>cdd c:\documents and settings

C:\Documents and Settings>cdd d:\data

D:\data>

jet
  • 2,733