Jump to content
Sign in to follow this  
O(V)eGA_l2el)

Batch file w/ spaces

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
Try enclosing the directory name in quotes like this: cd "H:\Directory One\Subdirectory\fileonedirectory"

 

Enclosing that line does not work; the results remain the same (can not find fileone.exe).

Share this post


Link to post
Share on other sites

What about: start "H:\Directory One\Subdirectory\fileonedirectory\fileone.exe"

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×