Get the path of Script

I am using a batch file to create a model using a python script that I have written

The scripts are located in various folders.

I need to save the model generated in the same folder.

I am using
file_save_location,tail=os.path.split(_ file _)

to get the path of the script that is currently running.

This gives me the file_save_location when I run the Rhino through the PythonEditor

But does not work when I call it through the batch file.

Can anyone tell me what is going wrong here.

@alain, any ideas?

Hi lpashwin,

Can you elaborate on exactly how you’re running the batch file?


If your script has been saved, this might be done using rs.LastLoadedScriptFile() but it is not yet implemented in rhinoscript syntax. Alternatively you could use this on windows to retrieve the script path with filename, then get the dirname from that:

import os
rp = os.path.realpath(__file__)
print os.path.dirname(rp)

@Alain could you please add rs.LastLoadedScriptFile() to rhinoscript syntax ?


1 Like

Rhinoscriptsyntax has DocumentPath() which does the same thing ( I’d like to know too how you’re running the batch file though.