Q:

Pass path names with spaces to command line

I am passing the following commandString to a script with paths and params:
"C:/Users/User/Documents/MyVersions/my test scripts/script_to_process.exe" -i "C:/Users/User/Documents/Mapping/Test_Process/file mapping.xlsx" -p "File Mapping" -s "ALL" -tc "V" -sc "O"
Like so:
returnCode = os.system(commandString)

This works just fine unless I have a directory with spaces in its name. I have, on the advice of other SO questions, added double spaces around the path and still no joy...
What is even more frustrating is that while this path DOES NOT work...
"C:/Users/User/Documents/MyVersions/my test scripts/script_to_process.exe"
This path which also has a space (though it is in a file rather than a directory) DOES...
"C:/Users/User/Documents/Mapping/Test_Process/file mapping.xlsx"
Last bit of info., when I pass this in the path it fails at the 1st space (after my)...
'C:/Users/User/Documents/MyVersions/my' is not recognized as an internal or external command,
operable program or batch file.
Do I need to do anything special to handle directory names? Is that it? If not can anyone help me with what I am doing incorrectly?

A:

Thank you to Kevin He for getting me to further research spaces in path names - esp. as it relates to os.system. I finally found the answer at:
Eli Bendersky's website
TL;DR - I have more than one item wrapped in double qoutes and this is no bueno - this is a problem with the Windows cmd.exe processor, not the os.system call.
Eli's solution is to wrap the entire command line call in a double qoute and this worked for me...

