how to address files having spaces in their names

i wonder how does any os address file having spaces in their names.
Even cmd.exe in windows can't access such file but windows explorer can.
How is it so?
Last edited on
cmd.exe can.

You have to quote names with spaces, e.g.

md "folder name with spaces"

So the command line parser knows you want to pass "folder name with spaces" as a single argument to md, rather than the four arguments "folder", "name", "with", and "spaces".

In this example,

md folder name with spaces

creates four folders, but

md "folder name with spaces"

just the one.


Last edited on
I have made a command line program too, but how do i make my program to access such files. Or should the user type the filename the same in cmd.exe
You should advise the user to quote paths which contain spaces. This is common enough requirement that it won't be an issue.

But you could just splice the arguments together, with a single space between them, to form a file path and then try that. (It appeats to be what notepad.exe does.)

dir "* *"

and in Linux, it uses "\ " to escape a blank
Topic archived. No new replies allowed.