views:

328

answers:

3

The batch file is something like this, I put the python in some directory that has SPACE character in its path.

C:\"Documents and Settings"\Administrator\Desktop\bracket\python\python 
C:\\"Documents and Settings"\\Administrator\\Desktop\\bracket\\[10,20]\\brackettest.py

When I run this one, I get this error.

C:\Documents and Settings\Administrator\Desktop\bracket\python\python: can't ope
n file 'C:\Documents and Settings\\Administrator\\Desktop\\bracket\\[10,20]\\bra
ckettest.py': [Errno 2] No such file or directory
C:\Documents and Settings\Administrator\Desktop\bracket>

What might be wrong?

Wrapping the path doesn't solve this problem.

"C:\\Documents and Settings\\Administrator\\Desktop\\bracket\\[10,20]\\brackettest.py"

Are the brackets ('[]') cause of the problem? On Mac, python works well with bracket character.

+3  A: 

There's no backslash escaping in the Windows console, it should read

"C:\Documents and Settings\Administrator\Desktop\bracket\python\python" "C:\Documents and Settings\Administrator\Desktop\bracket\[10,20]\brackettest.py"
AndiDog
This definitely works. Make sure the file really exists. You can use tab completion in the console prompt or `dir` in the directory `[10,20]`.
AndiDog
Yes, it worked. I got something wrong. Thanks for the help.
prosseek
You can only use tab completion on [10,20] if the open quote is already there, fwiw. I tried from a relative path, without quotes, and cmd.exe treated the bracketed item like it wasn't even there. "cd c:\test\[10,20]<Tab>" gave me the first item in the c:\test folder stuck on the end of [10,20]. Not entirely useful, but if I put a quote before c: then it worked correctly.
dash-tom-bang
+2  A: 

Looks like you almost had it; just replace the double-slashes with single slashes.
If you're ever unsure and need a reminder of the right format. Try using the tab key to automatically complete your folder or filename. For example, at your command prompt just type:
C:\docu
then hit the tab key and it will automatically complete your folder name. From there you just type in the rest. Whenever you want to automatically complete the rest of the folder or filename, just hit the tab key. This will always produce a properly specified path that is runnable.

Joe L.
A: 

Can you

cd "\Documents and Settings"
cd "\Documents and Settings\Administrator\Desktop\bracket\python\python"
cd "\Documents and Settings\Administrator\Desktop\bracket\"
cd "\Documents and Settings\Administrator\Desktop\bracket\[10,20]\"

If all that works, do

cd "\Documents and Settings\Administrator\Desktop\bracket\python\python"
python "\Documents and Settings\Administrator\Desktop\bracket\[10,20]\brackettest.py"

Why do you have such a weird, nondescriptive dirname ([10,20])? Didn't even know that NTFS allowed that.

voyager
@voyager - It's not my fault, I have no choice but to use the silly directory from the testing system. :(
prosseek