Jump to content

Batch file w/ spaces


O(V)eGA_l2el)

Recommended Posts

I have noticed one of my batch files contains a directory name with a space and does not execute correctly. Although, other batch files containing names with spaces execute with no problems. What am I overlooking in this particular batch file. Should I use quotation marks, a tilde, or some other character to signify a space within filenames?

 

Syntax Example:

 

@echo off

echo Starting fileone...

cd H:\Directory One\Subdirectory\fileonedirectory

start fileone.exe

Share this post


Link to post
Share on other sites

I have noticed one of my batch files contains a directory name with a space and does not execute correctly. Although, other batch files containing names with spaces execute with no problems. What am I overlooking in this particular batch file. Should I use quotation marks, a tilde, or some other character to signify a space within filenames?

 

Syntax Example:

 

@echo off

echo Starting fileone...

cd H:\Directory One\Subdirectory\fileonedirectory

start fileone.exe

Try enclosing the directory name in quotes like this: cd "H:\Directory One\Subdirectory\fileonedirectory"

Share this post


Link to post
Share on other sites

According to the CD help documentation:

 

CHDIR command does not treat spaces as deliminiters [...] so it is possible to CD into a directory with a space.

 

So chances are you've got the directory wrong, or you're not CDing correctly. Ah heck, I'll quote it:

 

Microsoft Windows XP [Version 5.1.2600]

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...