Command prompt won't change directory to another drive

Command LineCmdDirectoryCommand Line-InterfaceCommand Prompt

Command Line Problem Overview


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?

Command Line Solutions


Solution 1 - Command Line

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.

Solution 2 - Command Line

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>

Solution 3 - Command Line

Use drive letter d for changing to D drive like:

  C:\> d:

When changing drives, you just need to type the drive letter, like d: (don't use the backslash, like d:; it doesn't work).

> You only use cd when moving between directories within the same drive.

Solution 4 - Command Line

The short answer

The correct way to go from C:\...\Adminto D:\Docs\Java drive, is the following command :

cd /d d:\Docs\Java

More details

If you're somewhere random on your D:\ drive, and you want to go to the root of your drive, you can use this command :

cd d:\

If you're somewhere random on your D:\ drive, and you want to go to a specific folder on your drive, you can use this command :

cd d:\Docs\Java

If you're on a different drive, and you want to go to the root of your D:\ drive, you can use this command :

cd /d d:\

If you're on a different drive, and you want to go to a specific folder on your D: drive, you can use this command :

cd /d d:\Docs\Java

If you're on a different drive, and you want to go to the last open folder of you D: drive, you can use this command :

cd /d d:

As a shorthand for cd /d d:, you can also use this command :

d:

Solution 5 - Command Line

you should use a /d before path as below :

cd /d e:\

Solution 6 - Command Line

In order to move to D drive in windows use, C:\Users\Balaji>d:

In order to move to E drive use, C:\Users\Balaji>e:

same will be applicable for other drives.

Solution 7 - Command Line

If you want to change from current working directory to another directory then in the command prompt you need to type the name of the drive you need to change to, followed by : symbol. example: assume that you want to change to D-drive and you are in C-drive currently, then type D: and hit Enter.

On the other hand if you wish to change directory within same working directory then use cd(change directory) command followed by directory name. example: assuming you wish to change to new folder then type: cd "new folder" and hit enter.

Tips to use CMD: Windows command line are not case sensitive. When working with a file or directory with a space, surround it in quotes. For example, My Documents would be "My Documents". When a file or directory is deleted in the command line, it is not moved into the Recycle bin. If you need help with any of command type /? after the command. For example, dir /? would give the options available for the dir command.

Solution 8 - Command Line

You can change directory using this command like : currently if you current working directoris c:\ drive the if you want to go to your D:\ drive then type this command

cd /d D:\

now your current working directory is D:\ drive so you want go to Java directory under Docs so type below command :

cd Docs\Java

note : d stands for drive

Solution 9 - Command Line

An easier way is to use PowerShell instead, that not require any additionnal flag:

W:\> cd C:\path\on\different\disk

Solution 10 - Command Line

I suppose you are using Windows system.

Once you open CMD you would be shown with the default location i.e. like this

C:\Users\Admin - In your case its admin as mentioned else it will be the username of your computer

Consider if you want to move to E directory then simply type E:

This will move the user to E: Directory. Now change to what ever folder you want to point to in E: Drive

Ex: If you want to move to Software directory of E folder then first type

E:

then type the location of the folder

cd E:\Software

Viola

Solution 11 - Command Line

The cd command on Windows is not intuitive for users of Linux systems. If you expect cd to go to another directory no matter whether it is in the current drive or another drive, you can create an alias for cd. Here is how to do it in Cmder:

  • Go to $CMDER_ROOT/config and open the file user_aliases.cmd
  • Add the following to the end of the file:
cd=cd /d $*

Restart Cmder and you should be able to cd to any directory you want. It is a small trick but works great and saves your time.

Solution 12 - Command Line

you can use help on command prompt on cd command by writing this command cd /? as shown in this figure enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnebuchView Question on Stackoverflow
Solution 1 - Command LinekennyView Answer on Stackoverflow
Solution 2 - Command LineNasreddineView Answer on Stackoverflow
Solution 3 - Command LineKrishnaView Answer on Stackoverflow
Solution 4 - Command LineJohn SlegersView Answer on Stackoverflow
Solution 5 - Command LineAbolfazl MiadianView Answer on Stackoverflow
Solution 6 - Command LineBalaji DinakaranView Answer on Stackoverflow
Solution 7 - Command LineVinayakView Answer on Stackoverflow
Solution 8 - Command LineHoque MD ZahidulView Answer on Stackoverflow
Solution 9 - Command LineDevMultiTechView Answer on Stackoverflow
Solution 10 - Command Lineuser2401863View Answer on Stackoverflow
Solution 11 - Command LinejdhaoView Answer on Stackoverflow
Solution 12 - Command LineMohammed AwneyView Answer on Stackoverflow