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

18

11

I am trying to cd to the Program Files directory, but I'm getting an error. Here is the screen shot.

PowerShell Error Message

Here's the command I'm running and the error message:

PS C:\> cd C:\Program Files

Set-Location : A parameter cannot be found that matches parameter name 'Files'. At line:1 char:3 + cd <<<< C:\Program Files

Harrison Brock

Posted 2012-09-23T17:19:04.447

Reputation: 291

1there's whitespace, escape it. – None – 2012-09-23T17:20:39.263

9cd "C:\Program Files" – Joachim Isaksson – 2012-09-23T17:21:24.183

Answers

14

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 backticks. Use the same character when you're typing. On my en-GB keyboard it is the character to the left of the 1 key.

Edit: ugh! my eyes! It's an apostrophe, not a backtick.

Andrew Morton

Posted 2012-09-23T17:19:04.447

Reputation: 2 366

30

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

cd "C:\Program Files"

Ryan Kempt

Posted 2012-09-23T17:19:04.447

Reputation: 428

8

You can also use the ProgramFiles environment variable

cd $env:ProgramFiles

Shay Levy

Posted 2012-09-23T17:19:04.447

Reputation: 349

3

Try this

C:\>cd "Program Files"

This will work.

bashu

Posted 2012-09-23T17:19:04.447

Reputation: 151

1

METHOD1: With Quotes

cd "C:/Prgram Files (x86)"

cd 'C:/Program Files (x86)'

Method2: Without using Quotes

cd Program\ Files \(x86\)

Similarly it will go for Program Files.

shaurya uppal

Posted 2012-09-23T17:19:04.447

Reputation: 141

-2

Try then 8.3 filename version:

cd C:\Progra~1

Also try:

cd C:\Program*

John

Posted 2012-09-23T17:19:04.447

Reputation: 1

-3

You should try with

cd C:\Program\ Files

lfalorni

Posted 2012-09-23T17:19:04.447

Reputation:

Even the suggested edit is wrong. Declined. – music2myear – 2018-12-21T22:04:51.063

2No, he shouldn't. The backslash is a path separator here, not an escape character. He must either quote the path (as has already suggested) or escape spaces with backticks: cd C:\Program\ Files` – Ansgar Wiechers – 2012-09-23T17:28:39.110