239

I'm using cmd.exe (C:\WINDOWS\System32\cmd.exe) and I have to change my current directory to "D:\temp" i.e. temp folder in the D drive.

When I try to cd nothing happens.

C:\> cd D:\temp

C:\>

I don't know what else to do here. Even pressing tab key does not give any hints. I have never got the reason to use cmd.exe until now when I have to. I mostly use Linux for development.

If this helps: I'm on a remote login to another computer and D:\temp in on the remote machine, but so is C:\ where I have opened the terminal (cmd.exe).

Mofi
  • 46,139
  • 17
  • 80
  • 143
A. K.
  • 34,395
  • 15
  • 52
  • 89
  • 23
    only add `D:` or `C:` not required cd.. – marlonpya May 26 '17 at 19:17
  • 28
    Why is this closed as off-topic? CMD can be used in programming, for an instance related to ADB (Android debug bridge) and it can also be used to execute programs in other languages (e.g. C, Java, Python, etc). If the target is in a different drive, the command is used to open the appropriate drive. I would say it directly involves tools used in programming, as it can be used for so many different programming-related things includin, but not limited to, ADB, launching programs, etc – Zoe Jun 07 '17 at 13:30
  • 4
    This applies to cmd command files :) - shouldn't be off topic – chris31389 Jun 06 '18 at 07:27
  • 3
    Again a great example of a good question, but some programmers being way too strict or having something up their a*, which results in that a proper question gets closed as off topic or for some other reason. Happy to see the large number of upvotes. – WJA Jan 31 '19 at 11:58
  • Yeah, the first time it was closed shortly after being asked and I was kinda stuck for a bit because i was too new to Windows command line. I'm glad this question has already helped more than 800k people. – A. K. Aug 23 '21 at 05:20

8 Answers8

425

The "cd" command changes the directory, but not what drive you are working with. So when you go "cd d:\temp", you are changing the D drive's directory to temp, but staying in the C drive.

Execute these two commands:

D:
cd temp

That will get you the results you want.

Mark Nenadov
  • 6,421
  • 5
  • 24
  • 32
  • 8
    this does not work if cd command is executed for environment variable, for example `cd %temp%`. In case if current drive differs from temp folder drive `cd %temp%` do nothing. `cd /d %temp%` should be used as @Stephan said – oleksa Nov 17 '15 at 11:26
  • 3
    **i.e** First change the **Drive** then change the **Folder** or directory, hope helps someone. – Shaiju T Aug 27 '16 at 15:24
  • 1
    I ran second first and when I used Drive name it automatically went to directory so cd temp, D: also work – abdul qayyum Feb 09 '18 at 11:30
151

Another alternative is pushd, which will automatically switch drives as needed. It also allows you to return to the previous directory via popd:

C:\Temp>pushd D:\some\folder
D:\some\folder>popd
C:\Temp>_
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
135

cd has a parameter /d, which will change drive and path with one command:

cd /d d:\temp

( see cd /?)

Stephan
  • 53,940
  • 10
  • 58
  • 91
5

You can try this it works for me

C:\Users\user>cd..
C:\Users>cd ..
C:\>D:
D:\>cd \foldername
4

Use Command

G:\ D:         <!--Move to D Drive-->

D:\ cd temp      <!--Move to temp Folder-->
Munna Kumar
  • 377
  • 4
  • 7
2

Just type your desired drive initial in the command line and press enter

Like if you want to go L:\\ drive, Just type L: or l:

danialcodes
  • 175
  • 2
  • 1
-2
cd /driveName driveName:\pathNamw
  • gives me `The filename, directory name, or volume label syntax is incorrect.`. Of course it does, because `/drivename` is not a valid switch and therefore interpreted as a foldername, which doesn't exist. – Stephan Jan 04 '21 at 08:13
-3

You can use these three commands: 1.cd.. 2.d: 3.cd temp