The Computer Oracle

Cannot cd to a folder with spaces in the the folder path

--------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Romantic Lands Beckon

--

Chapters
00:00 Question
01:02 Accepted answer (Score 16)
01:32 Answer 2 (Score 43)
01:47 Answer 3 (Score 8)
02:02 Answer 4 (Score 5)
02:15 Thank you

--

Full question
https://superuser.com/questions/478679/c...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#powershell

#avk47



ANSWER 1

Score 45


You need to surround the path in double quotes if there is a space in the path!

cd "C:\Program Files"



ACCEPTED ANSWER

Score 16


Type cd c:\ . Now press the tab key (this is auto-complete, which will save you a lot of typing) repeatedly until it shows you a directory with spaces in the name. Notice how it delimits the path with apostrophes '. Use the same character when you're typing.

Edit: Make sure to use an apostrophe, not a backtick.




ANSWER 3

Score 8


You can also use the ProgramFiles environment variable

cd $env:ProgramFiles



ANSWER 4

Score 5


Try this

C:\>cd "Program Files"

This will work.