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

Perhaps a silly question, but are you sure you have the path right? I think enclosing in "'s should actually work...

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...