Is current working directory set to location of opened .blend?

For people that launch via terminal, it should just be the directory in which the program is invoked, but I’m not sure what happens (on all 3 platforms) when blender is launched via some GUI (like clicking on a .blend file to open it).

If anyone here knows explicitly, please confirm this one way or the other.

If not, I would appreciate it if you could test this on your own platform:

Open a .blend, and post the result of running the following script (via “Run Script”):


import os
import bpy

print("-----------------------------------")
print(os.getcwd())
print(bpy.path.abspath("//"))
print("-----------------------------------")

I’m getting:

C:\Program Files\Blender Foundation
C:\Program Files\Blender Foundation\

Note that I ran this in a blendfile that was saved in C:\Program Files\Blender Foundation\

Win64 7

Edit: the documentation says that os.getcwd() is available on Windows and Linux


Windows Xp professional, 32 bits.

Use bge rather than bpy

Ok, based on these tests, it seems like blender doesn’t do anything internally; the current working directory may, or may not be set by the system to be that of the opened file.

That’s all I needed to know - Thanks guys.

@ Monster

I’m working on a blender plug-in, so bpy is the right module … Although, maybe I should have asked this in the Python forum.

Anyway, I got my answer.

This is on Windows. If you load Blender first then open a project then the CWD is where Blender is. If you double click on a blend file then the CWD is the location of the blend.