Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command prompt won't change directory to another drive

I'm trying to compile some java (learning java currently), and to do so I need to change command-prompt's directory.

C:\...\Admin> cd D:\Docs\Java C:\...\Admin> cd C:\...\Admin 

It doesn't change the directory. I try again using quotes:

C:\...\Admin> cd "D:\Docs\Java" C:\...\Admin> 

Again it doesn't change the directory. What am I doing wrong?

like image 362
nebuch Avatar asked Jun 16 '12 17:06

nebuch


People also ask

Why does Command Prompt not change directory?

How to fix: When you need to change to another drive, you don't need to use CD command and it won't work, you can just type the drive letter followed by a colon, e.g. D:. If you want to change the directory and folder path at the same time, you can use add the “/d” switch after CD command, e.g. cd /d d:\PS.

How do I move a directory to the D drive in Command Prompt?

If, in contrast, you want to change your directory altogether, then you'll have to type the drive name, followed by :. So, if you're in the “C:” drive right now, and you'd like to move in to your “D:” drive, just type in “D:” in the Command prompt and hit the Enter.


2 Answers

As @nasreddine answered or you can use /d

cd /d d:\Docs\Java 

For more help on the cd command use:

C:\Documents and Settings\kenny>help cd 

Displays the name of or changes the current directory.

CHDIR [/D] [drive:][path] CHDIR [..] CD [/D] [drive:][path] CD [..]

.. Specifies that you want to change to the parent directory.

Type CD drive: to display the current directory in the specified drive. Type CD without parameters to display the current drive and directory.

Use the /D switch to change current drive in addition to changing current directory for a drive.

If Command Extensions are enabled CHDIR changes as follows:

The current directory string is converted to use the same case as the on disk names. So CD C:\TEMP would actually set the current directory to C:\Temp if that is the case on disk.

CHDIR command does not treat spaces as delimiters, so it is possible to CD into a subdirectory name that contains a space without surrounding the name with quotes. For example:

cd \winnt\profiles\username\programs\start menu

is the same as:

cd "\winnt\profiles\username\programs\start menu"

which is what you would have to type if extensions were disabled.

like image 81
kenny Avatar answered Oct 02 '22 00:10

kenny


The directory you're switching to is on another drive, you need to switch to that drive using :

C:\...\Admin> d: 

then you can cd into the directory you want.

C:\...\Admin> d: D:\>cd "Docs\Java"  D:\Docs\Java> 
like image 40
Nasreddine Avatar answered Oct 02 '22 00:10

Nasreddine