Share this question

Welcome to Teachnovice Q&A, where you can ask questions and receive answers from other members of the community.

This is a collaboratively edited question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I escape spaces in command line in Windows without using quotation marks?

0 like 0 dislike
7,036 views

For example what is the alternative to this command without quotation marks:

CD "c:\Documents and Settings"

The full reason I don't want to use quotation marks is that this command DOES work:

   SVN add mypathname\*.*

but this command DOES NOT work :

   SVN add "mypathname\*.*"

The problem being when I change mypathname for a path with spaces in it I need to quote the whole thing. For example:

SVN add "c:\Documents and Settings\username\svn\*.*"

But when I try this I get the following error message:

svn: warning: 'c:\Documents and Settings\username\svn\*.*' not found
asked Apr 24, 2013 by anonymous  
Have you tried SVN add "c:\Documents and Settings\username\svn\"*.* or SVN add "c:\Documents and Settings\username\svn"\*.* ?
and @WeltenWanderer nice try but unfortunately this doesn't work. In all 3 cases I get an "svn: Error resolving case of ....."
Trying to work around the problem, you could use junctions (en.wikipedia.org/wiki/NTFS_junction_point) to create paths without spaces in them
Have you tried old 8.3 formatting of the name ( DOCUME~1 )?
Just to be pedantic, you don't need quotes with cd, even when there are spaces in the path. Couldn't you just use cd and then make a temporary %variable% from it, and use that?

3 Answers

0 like 0 dislike
 
Best answer

It almost all works for me, but have you perhaps tried line5.. escaping the space with a caret symbol (^)

C:\Documents and Settings\user>cd ..

C:\Documents and Settings>cd ..

C:\>cd Documents and Settings

C:\Documents and Settings>cd..

C:\>cd Documents^ and^ Settings

C:\Documents and Settings>cd..

C:\>cd C:\documents and settings

C:\Documents and Settings>cd..

C:\>

Looks like the caret symbol may be your answer

C:\>"c:\Documents and Settings\a.bat"
gaga

C:\>c:\Documents and Settings\a.bat
'c:\Documents' is not recognized as an internal or external command,
operable program or batch file.

C:\>c:\Documents^ and^ Settings\a.bat
gaga

C:\>
answered Apr 24, 2013 by anonymous  
you could also try cygwin's svn, if curious.. with some of the example answers in that question and see if any or variations of them work for you.
The caret symbol does directly answer my question so I'll accept your answer. Unfortunately the SVN command doesn't seem to recognise it! If I try it I get this error message "svn 'C:' is not a working copy". I have another way around it though and that's to simply 'cd' to the directory first then execute the SVN command once there. I can even chain the two commands together in a single line using the && operator: cd "c:\Documents and Settings\username\svn" && SVN add *.*
since subversion is a programmer's tool, it may be appropriate for SO. here is a related question http://www.teachnovice.com/2234/how-to-escape-%40-characters-in-subversion-managed-file-names it could be you use quotes or caret to get it to svn, then perhaps you use backslash before each space
0 like 0 dislike

Use the 8.3 short-filename. For example:

If exist c:\docume~1 goto :Ifoundthesucker
answered Apr 24, 2013 by anonymous  
0 like 0 dislike

I found that putting quotes around just one part of the location works. In your case:

SVN add C:\"Documents and Settings"\username\svn\*.*
answered Apr 24, 2013 by anonymous  
...