Running python batch file that has a path with SPACE character


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]\\

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': [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]\\"

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

4/7/2010 4:44:26 PM

Accepted Answer

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]\"
4/7/2010 4:38:08 PM

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:
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.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow