How to start/open a file/folder that contains space in its name through command-line?

24

6

I'm trying to use the start command in the command prompt to open files and folders, but I'm unable to open files and folders that contain space(s) in their name.

I have tried the following queries (testing on C:\Program Files):

start C:\Program Files
start C:/Program\ Files
start C:/"Program Files"
start C:\"Program Files"
start "C:\Program Files"
start "C:/Program Files"
start C:/Program_Files
start C:/Program%20Files

But none of them work.

amiregelz

Posted 2012-11-27T20:18:23.450

Reputation: 6 965

4Not strictly speaking the answer you're looking for (hence posted as a comment), but start c:\progra~1 will do the trick. – Bryan – 2012-11-27T20:21:48.473

Answers

23

You would use:

start "" "c:\program files\"

That is because the first parameter is used as the title of the window, and is oddly enough, enclosed in double quotes.

Edit:

Here is a source about it: SS64

As an example, if you just type start "title" it opens a new cmd window with the title "title" in the title bar.

nerdwaller

Posted 2012-11-27T20:18:23.450

Reputation: 13 366

3What's with the empty one? – Cole Johnson – 2012-11-27T20:25:45.360

1+1; interesting, would love to know how this works? – Bryan – 2012-11-27T20:26:47.323

3It's a title for the window, the parameter is enclosed in double quotes for some stupid reason. I rarely use Windows, especially when they do this stuff that makes little sense to me. In linux the CLI would be -t or whatever for title. – nerdwaller – 2012-11-27T20:27:10.817

Wow, trust who else but Microsoft to come up with something like that! – Bryan – 2012-11-27T20:28:56.850

A simple start /? would have clarified the params for the OP instead of struggling so much. As for "the parameter is enclosed in double quotes for some stupid reason", type start "Isn't it obvious?" cmd with and without quotes and see if you can figure out why the quotes might be required. – Karan – 2012-11-28T00:18:14.687

2Yes, it is obvious why quotations are needed. However, why that is not an optional parameter is not. That's the question. – nerdwaller – 2012-11-28T01:08:28.750

"the first parameter is used as the title of the window, and is oddly enough, enclosed in double quotes" and "the parameter is enclosed in double quotes for some stupid reason" implied you were talking about the quotes and were puzzled as to why they were required. As for why they didn't make the parameter optional, I doubt we'll ever know why but I totally agree that it wasn't a great idea. (BTW, if you don't use @, people are not informed of your comments.) – Karan – 2012-11-28T01:23:10.307

Ah yes, I was unclear. And I know, but I assumed you would check back. Typically I do it, thanks! – nerdwaller – 2012-11-28T01:26:22.927

13

Do you specifically need to use start?

You can use explorer "c:\program files" to give you the effect you are looking for.

Bryan

Posted 2012-11-27T20:18:23.450

Reputation: 1 563

1Didn't know about this one. Is there any difference between start and explorer? – amiregelz – 2012-11-27T20:38:10.027

Start is built to run a command through, so it would build a window and run a script. Explorer opens explorer, plain and simple. – nerdwaller – 2012-11-27T20:40:30.977

This article details some command line switches (work on Win 7, despite it specifying Win XP) that do funky things, such as open an explorer window and highlight a specific file, e.g. explorer /select,c:\Windows\System32\calc.exe – Bryan – 2012-11-27T20:42:41.347

2@nerdwaller, explorer, will also launch an app, e.g. explorer c:\Windows\System32\calc.exe. – Bryan – 2012-11-27T20:43:24.033

1I apologize for omitting that. Documents and such as well explorer Documents\example.xlsx Thank you for pointing it out! I always wonder how people can work in the normal CMD, after working through the linux terminal... Haha. Autocomplete is a joke for commands...! – nerdwaller – 2012-11-27T20:45:13.333

1

If you are already in the current directory, you could always do this.

C:\>cd "C:\Program Files"

C:\Program Files>start .

C:\Program Files>

dmcgill50

Posted 2012-11-27T20:18:23.450

Reputation: 536

And even explorer . will work – Neerali Acharya – 2019-06-04T11:28:42.700

0

Use url encoding

// assign base path initially from a filename

var basePath = Path.GetDirectoryName(doc.Filename);

this.BaseUri = new Uri($"file:///{basePath}"); // add file:/// prefix

user1118961

Posted 2012-11-27T20:18:23.450

Reputation: 1

0

Type cd space and press Tab it will give you the directory items list, simple.

vishal sharma

Posted 2012-11-27T20:18:23.450

Reputation: 212