289

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).

6
  • 31
    only add D: or C: not required cd.. Commented May 26, 2017 at 19:17
  • 29
    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 Commented Jun 7, 2017 at 13:30
  • 5
    This applies to cmd command files :) - shouldn't be off topic Commented Jun 6, 2018 at 7:27
  • 4
    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. Commented Jan 31, 2019 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. Commented Aug 23, 2021 at 5:20

10 Answers 10

492

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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
i.e First change the Drive then change the Folder or directory, hope helps someone.
I ran second first and when I used Drive name it automatically went to directory so cd temp, D: also work
165

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>_

2 Comments

Perfect answer. No worries on source folder.
Way easier than going up and down folder levels!
157

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

cd /d d:\temp

( see cd /?)

1 Comment

It's an excellent alternative to TCC/LE CDD: jpsoft.com/help/cdd.htm?q=cdd
11

Use Command

To Move to D Drive

G:\ D:         

To Move to temp Folder

D:\ cd temp      

Comments

8

You can try this it works for me

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

1 Comment

can we do this in single command.
3

A powerful thing is the help provided by the command itself. cd /? will output some useful information about cd. enter image description here

The argument /D will change directory and drive, if specified in the path. Single command, no workaround:

cd /D path

Comments

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:

Comments

2

Need to move from one directory or folder to another just do this:

Here is the folder structure as- Folder structure

And this is works for me -- Enter the command --

D:\CipharByteIntern\Razorpay\razorpay_frontend> cd ../..\CBTCIP\EventPlanner360

-- Navigated folder ---

D:\CipharByteIntern\CBTCIP\EventPlanner360>

1 Comment

This is great - prevents the need from traversing the folder tree in two separate steps. NEAT!
-2
cd /driveName driveName:\pathNamw

1 Comment

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.
-4

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.