Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Using cd Command in Windows Command Line, Can't Navigate to D:\
Why wouldn't cd <drive letter>: work?

This is what I found when trying to go from one directory to another in windows7 using cmd. Reproduced below (in bolds) is the terminal and later I explain my question

C:> cd k:\folder1\folder2

C:>k:

k:\folder1\folder2>**

In the first line, it did not allowed me to enter into the desired location. In second line, when I just wanted to go into the k directory, it sent me to the address which I typed in previous command.

Question: Why, in second command, on just typing 'k:', i find myself in 'k:\folder1\folder2'?

Thanks.

share|improve this question

marked as duplicate by techie007, Moab, Mike Fitzpatrick, random Mar 2 '12 at 5:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Quick answer: C:>k: is still in C:, you can't cd across drives. You switch drives by using the /D switch. –  Breakthrough Mar 2 '12 at 4:13
    
I do not understand the > In the first line, it did not allowed me to enter into the desired location. part of your question, Could you elaborate further? As for the second part of the question, have a look at this article, it clearly explains: > In second line, when I just wanted to go into the k directory, it sent me to the address which I typed in previous command. > Question: Why, in second command, on just typing 'k:', i find myself in 'k:\folder1\folder2'? –  Bhargav Bhat Mar 2 '12 at 4:20
    
Thanks. Second question (Using cd Command in Windows Command Line, Can't Navigate to D:), while not the same, has the top answer which answers my question. Here is the link for the answer. superuser.com/a/135217/120951 –  kk_139 Mar 2 '12 at 4:28
    
No one here has quite answered the question correctly. To understand why this happens, we need a time machine. I'll let Raymond Chen tell you why this is the case: blogs.msdn.com/b/oldnewthing/archive/2010/10/11/10073890.aspx –  surfasb Mar 4 '12 at 0:24
add comment

2 Answers

When you run cd and specify a full path, with drive letter, it changes the working directory for that drive. It will not by default switch you over to that drive, however. This allows you to execute some commands on the other drive, using programs in the current path, without having to type the whole path for the other drive into command parameters.

Consider the following example, where you have not included your MyBatchFiles folder in %PATH%, and you've got to run a script against some files deep in the file system on D:. Here, the script is just copy %1 %2 but it really could be anything that needs to work on an arbitrary target on another drive. See how execution of this command on subsequent files requires much less typing than if I'd had to specify the full path every time.


enter image description here


Now, if you really want to change to a directory on another drive and switch to that drive, you just need to use the /d switch. See below.


enter image description here


share|improve this answer
add comment

The command shell retains values for the current drive, and the current directory on each drive. When you type CD, it only changes the current directory for the current drive or the specified drive. Changing to a drive will put you in that drive's current directory.

To change drive and directory at once, you can use:

CD /D K:\folder1\folder2

Also, you can use this method to use shorthand in other commands:

CD J:\folderA\folderB
CD K:\folder1\folder2
Copy J:*.* K:

Will copy all files from J:\folderA\folderB to K:\folder1\folder2, even if you're in the C: drive. Note the lack of slashes in the Copy command.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.