2

I am working with both Docker Quickstart Terminal (Bash) and Cmder on Windows10.

On Bash, to change directory to a path where some folder contains spaces, I usually do:

cd "D:\my files\etc\etc"

as I launch the same on Cmder, it does not work, but neither it responds with some warning indicating wrong syntax.

I tryed also

cd "D:/my files/etc/etc"

but nothing.

So how do I change my current directory in Cmder ?

(it has to work with directories having spaces in their names)

4
  • Windows CMD - which will be the command processor in CMDER if it's not PowerShell - generally wants \ rather than / in pathnames. May 7, 2021 at 13:46
  • I tryed both \ and /
    – Tms91
    May 7, 2021 at 13:49
  • 1
    Also, cd will not change your current drive, only the directory on the specified drive. If your current path is C:\Users\Foo\Documents and you type CD D:\Bar\Quux, your current directory will still be C:\Users\Foo\Documents; you will have to type D: to actually change the drive as well. May 7, 2021 at 13:50
  • 1
    As a general comment regarding CMD - I recommend bookmarking SS64 on CMD, and if you also use PowerShell, SS64 on PowerShell - SS64 is clear, concise, and extensive if not fully complete, as a reference to command lines. May 7, 2021 at 14:03

2 Answers 2

2

SOLVED

turns out that in Cmder when you want to change directory from one driver to another (e.g. from C: to D: ), you have to insert a /d right after the cd command, where the d probably stands for "driver".

So in my case the solution is:

cd /d "D:\my files\etc\etc"

and

cd /d "D:/my files/etc/etc"

works too.

1
  • Urf. Yeah, I forgot about that switch... May 7, 2021 at 13:55
0

I'm surprised that the quotes don't work, but another approach can be to use a backslash \ character to escape a space. So for example, instead of:

cd "D:\my files\etc\etc"

you could try:

cd D:/my\ files/etc/etc.

I'm not sure I agree with Jeff's point that CMD prefers one slash over another, since my understanding was that Windows is fine with either and Unix-based systems require forward slashes.

2
  • 3
    Windows is fine with either programmatically - that is, in a program you write in e.g., C#, you can use paths with either / or \ - but the command processor CMD defaults to using / as the switch character, equivalent to the *ix -. Recent Windows seems to use - and / interchangeably as the switch character in most cases, but it's not behavior you can or should count on because some legacy command-line programs may not have been written to accommodate this. May 7, 2021 at 13:54
  • Good to know, thank you for clearing that up.
    – hunsbct
    May 7, 2021 at 13:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .