Command prompt won't change directory to another drive
Asked Answered
D

14

539

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?

Dynast answered 16/6, 2012 at 17:4 Comment(0)
G
976

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.

Galyak answered 16/6, 2012 at 17:40 Comment(8)
@SZaman in my experience. CD never changed drive letter without it.Galyak
@Galyak Indeed, it literally never has switched the drive letter, ever.Alexiaalexin
@Galyak I wish rather than just be idle and do anything when you attempt to change to a directory on a different drive, it would give you an error message saying "ERROR - the file you're trying to access resides on another driver. Specify -d..."Infirm
@Infirm yes it's a flaw for sure, just do it ;)Galyak
this isn't working for me in windows 11Aricaarick
For some reason it didn't work to use cd /d. Instead it worked by just applying a command /d first, then cd d:/.../yourfolder.Grout
@ConstantineKetskalo above was reported it doesn't work on Win11. I don't have or know. It has always worked when I needed it. Other work around answers here.Galyak
@Galyak funny: non of the listed commands work in cmd on windows 11 for me... Including the one I've mentioned above. I think it worked for me on windows 10 on a different machine.Grout
G
204

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>
Gd answered 16/6, 2012 at 17:11 Comment(2)
@Prageethgodage: assume, you are on C:\my Folder and have files on a folder at another (network)drive in Z: Do a cd z:\very\long\path\you\dontwant\to\write\each\time. You are still on C:\my Folder). Then you can just dir z: (will list files on your very-long-path) or copy z:*.jpg (note: NOT z:\*.jpg!), which will copy files form your very-long-path. A simple z:` will switch to your Z: drive, where you are in your very-long-path. Very convenient, if you work a lot on command prompt.Lapotin
why can't directly change to that directory? What the hell is going on their developers mind?!Momentarily
E
66

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.

Exploit answered 8/10, 2015 at 11:34 Comment(1)
This is the only right solution to change drives in Windows. Thank you!Repairer
A
43

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:
Apis answered 8/7, 2017 at 11:8 Comment(3)
Also, if you try switching to a network drive, my workaround was to go into the drive from Solution Explorer and type cmd on the address bar. That opens it upTouristy
For some reason, none of the ways worked for me except the shorthand method listed at the end.Megadeath
@Touristy Not the same thing but if you "shift+R_click" inside the folder you will have the option to open a terminal there. I have Powershell and WLS avaliable, if you need cmd you can type "cmd" and hit enter in the Powershell prompt.Palliate
R
40

you should use a /d before path as below :

cd /d e:\
Roi answered 6/12, 2017 at 16:1 Comment(1)
thanks this worked.. what is /d for?Majka
R
17

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.

Rillet answered 11/7, 2019 at 6:45 Comment(0)
D
10

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.

Dutiable answered 25/9, 2013 at 11:50 Comment(0)
M
6

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

Margravine answered 30/3, 2017 at 7:5 Comment(0)
E
4

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.

Echino answered 1/2, 2019 at 11:40 Comment(0)
W
4

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

W:\> cd C:\path\on\different\disk
Wingback answered 28/4, 2021 at 7:45 Comment(0)
H
3

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

Helvetia answered 26/8, 2018 at 21:53 Comment(0)
W
3

If you want to jump from C: Drive to any drive just type the drive name with colon like (E:) in Anaconda and Enter, Anaconda redirect you in that E:Drive.

Now take the folder path and use cd .\<<Folder_Path>> and then Enter.

I have put the screenshots for your reference: enter image description here enter image description here

Whittier answered 23/11, 2022 at 7:58 Comment(0)
K
2

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

Katowice answered 24/2, 2017 at 9:12 Comment(0)
L
1

Long story short:

While it indeed has been cd driveletter:\ before (e.g. cd d:\),

in Windows 10, it's driveletter:\ only (e.g. d:).

Lint answered 28/11, 2022 at 22:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.