P
Paul
bud-- said:I am trying to write a batch program to delete a file that has
"Documents and Settings" in the path. It does not work.
Trouble shooting from the "Command Prompt" ('DOS screen'):
the current directory is C:\Documents and Settings
========================
dir c:\p* [wild card *]
returns
Volume...
Volume Serial Number...
Directory of c:\
... <DIR> Program Files
=======================
dir c:\program*
returns
Volume...
Volume Serial Number...
Directory of c:\
... <DIR> Program Files
----------------------
both are as expected
=======================
dir c:\program * [space added m *]
returns
Volume...
Volume Serial Number...
Directory of c:\
File Not Found
Directory of C:\Documents and Settings [the current directory]
[list of files in that directory]
---------------------------
this is not as expected (compared to DOS) -----
directory of c:\ should have found "...<DIR> Program Files"
and "Directory of C:\Documents and Settings" should not appear
=====================
dir c:\programf* [omit the space]
returns
Volume...
Volume Serial Number...
Directory of c:\
File Not Found
---------------------------
again what I expect
==================================
dir c:\program%20*
dir c:\program%20f*
[I have seen %20 used as a space - ASCII 20 hex is space]
both same as above - File Not Found
======================
The command prompt does not seem to function when there is a space in
the path.
Any ideas on how to handle a path that requires a space?
Running XP Professional SP3 Build 2600
Have you considered some quote marks ? That's the kind of
thing that works in other OSes. And in some OSes, the single
quote character has a different effect than the double quote
character. (You end up mixing them, for different purposes.)
dir "C:\Documents and Settings"
For each scripting environment, you have to learn about
what can be used for quoting, what can be used to escape
the quote character, so it can be used for normal things.
And depending on the environment, how many "layers" of
escape characters are needed, so that at least one survives
until it hits the shell interpreter.
Example here, of someone using the terminology of scripting trivia...
http://www.robvanderwoude.com/escapechars.php
You just try the stuff, until it works.
http://www.computerhope.com/forum/index.php/topic,34613.0.html
Try a Google search like this, for more tutorials:
msdos escape quote characters
HTH,
Paul