2

I am a Windows noob here (coming from a linux background.) I am having a problem in the cmd prompt changing to a directory on a different drive. Either I haven't found any suitable answers for this particular scenario or I'm not searching with the correct terms. Here is the scenario...

I am on C:\ and I want to change to a directory say E:\specific\directory.

I know about the /E switch for cd, but it's not working in this case. More, I have C:\ and D:\ on an SSD and my E:\ is on an HDD, so they're on two different physical harddrives.

I can do

C:\> cd /D D:\specific\directory with no problem, but trying to

C:\> cd /E E:\specific\directory

I get the error The filename, directory name, or volume label syntax is incorrect.

The only way it lets me on the E:\ drive is with two commands i.e. if I do C:\> e: first, then it lands on the E:\ drive, then with a second cd command I can navigate to whatever directory I want on E:\. So is there any way that I can navigate from C:\ to a specific directory on E:\ in one command rather than two?

Thanks!

5
  • Incidentally, you should bookmark SS64 on CMD as an excellent on-line reference for the Windows command line - Windows still doesn't have a useful man(1) command... Apr 12 '18 at 14:43
  • You could use Linux on Windows 10. See Install the Windows Subsystem for Linux.
    – harrymc
    Apr 12 '18 at 15:01
  • Thank you @JeffZeitlin and EBGreen for your answers. However, I think you both may have missed a small detail in my question, and I also figured out what my problem was. I was using the command C:\> cd /E E:\specific\directory where I thought the switch flag was to use the letter for which drive you wanted to switch to, i.e. switch /E for the E:\ drive. But no, the actual flag is /D, so the command should be C:\> cd /D E:\specific\directory.
    – crob
    Apr 12 '18 at 15:02
  • I was just about to post that, crob - I've been a DOS user since the 80's and I did not know about the /d option until just now after doing a cd /? and reading the help and testing it out myself. Learned something new. Apr 12 '18 at 15:08
  • That is literally what @JeffZeitlin has in his answer
    – EBGreen
    Apr 12 '18 at 15:55
10

The /D switch is what you should be using. Per SS64 on CD, CD /D ... changes both drive and directory - regardless of what drive you are attempting to change to - so you would use CD /D E:\Specific\Directory.

3

As Jeff Zeitlin pointed out, you can use the /D switch however I would highly suggest using Powershell instead of cmd anyway. It is intended to be the replacement for cmd and in it this:

cd E:\specific\directory

Gives the behavior that you want. It also comes with some aliases that sort of "emmulate" *nix commands such as ls to make it a "little" more friendly to people making the transition to a windows shell.

2
  • I agree with the preference for PowerShell over cmd; however, it's not unusual for people to be irritated at answers to "how do I do this" being "don't do that, do this instead". I consider using aliases like cd or ls to be fraught with peril, however, because while they do analogous things in PowerShell, they don't work the same way - ls might be OK, but ls -al isn't going to work as expected. Apr 12 '18 at 14:46
  • 2
    Well, I can't control whether someone is irritated with my answer or not. As for aliases not exactly emmulating the nix equivalent that is why little is in italics.
    – EBGreen
    Apr 12 '18 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.