Launching Rhino from .bat and running command with space in path

Hi all,

I want to have a batch file that launches rhino and runs a python script saved on my computer. It works when there is no space character in the file path to the python file. Like this:
This works:

start "" /min "C:\Program Files\Rhino 8\System\Rhino.exe" /nosplash /runscript="-RunPythonScript C:\Scripts\MyScript.py"

However, when there is a space in the script path, Rhino seems to breaks up the string into two separate commands.
Does not work:

start "" /min "C:\Program Files\Rhino 8\System\Rhino.exe" /nosplash /runscript="-RunPythonScript C:\Scripts Folder With Space\MyScript.py"

I’ve tried using double quotes like "-RunPythonScript "C:\Scripts Folder With Space\MyScript.py"" but I can’t get anything to work.

Any suggestions? @dale I believe you provided similar guidance on the forum.

Thanks in advance!

Have you tried single quotes around the path (with the outer quotes still double)?

Yes, unfortunately that still fails. With this

start "" /min "C:\Program Files\Rhino 8\System\Rhino.exe" /nosplash /runscript="-RunPythonScript 'Y:\00 Digital\Scripts Folder With Space\MyScript.py'"

it gets stuck in Rhino on the space

image

This is just guesswork, based on usage in other applications; try three consecutive double quotes each side of the path.

Hi @Michael_H,

I’m afraid it looks like this just isn’t possible. But, if it is essential to have spaces in your python file path (and not underscores, say) then I do have a workaround.

Put the RunPythonScript part into a text file:

-RunPythonScript "Y:\00 Digital\Scripts Folder With Space\MyScript.py"

and place the text file somewhere where there isn’t a space in its path, for example:
D:\3D\McNeel\TestStart.txt

Then change the Rhino start part to use ReadCommandFile instead of RunPythonScript:

start "" /min "C:\Program Files\Rhino 8\System\Rhino.exe" /nosplash /runscript="-ReadCommandFile D:\3D\McNeel\TestStart.txt"

and I think that gives you what you want, albeit clunkily.

HTH
Jeremy

1 Like

Thanks Jeremy :slight_smile: that’s too bad that it’s not possible, but I appreciate the workaround!

Hi @Michael_H,

Try surrounding the path string with parenthesis.

For example:

"C:\Program Files\Rhino 8\System\Rhino.exe" /nosplash /runscript="-RunPythonScript (C:\Users\Dale\Documents\McNeel\Python Scripts\Dale.py)"

– Dale

2 Likes

Thanks @dale, that works. Could we get this into the Rhino documentation, please?

1 Like

You bet.

https://mcneel.myjetbrains.com/youtrack/issue/RH-80848

– Dale

1 Like