Need help dealing with spaces in NT paths.

piet at piet at
Wed Nov 17 05:56:21 EST 1999

>>>>> "T. C. Mits" <71351.356 at> (TCM) writes:

TCM> A simple example of the difficulty is:
>>>> os.system(r'"dir Program Files"')
TCM> Bad command or file name
TCM> 0

TCM> This is run at the root of C: for simplicity.

TCM> I also get:

TCM> os.popen(r'"dir Program Files"', "r")
TCM> Bad command or file name
TCM> <open file '"dir program files"', mode 'r'  at 795930>

TCM> What does that mean?

It means there is no program with the name: dir program files
You should use:

os.system(r'dir "Program Files"')
os.popen(r'dir "Program Files"', "r")
Piet van Oostrum <piet at>
Private email: Piet.van.Oostrum at

More information about the Python-list mailing list