I tried scripting with Blender but I am stuck on this problem.

I want so change the Scripts Folder from the Blender Preferences (Preferences → File Paths → Scripts )

screenshot of preferences with File Paths tab open

Is it possible to do this with Python in Blender directly?

Thank You :)


2 Answers 2


Preferences are found in bpy.context.preferences. Mostly the name of the next field match the name in the tab, roughly. You can check this by going to the python console and typing dir(bpy.context.preferences). It will print something like this:

['__doc__', '__module__', '__slots__', 'active_section', 'addons', 'app_template', 'autoexec_paths', 'bl_rna', 'edit', 'experimental', 'filepaths', 'inputs', 'is_dirty', 'keymap', 'rna_type', 'studio_lights', 'system', 'themes', 'ui_styles', 'use_preferences_save', 'version', 'view']

From this we see that filepaths is the right field. To find the actual name for the scripts directory, make sure you have enabled Developer Extras and Python Tooltips in Preferences → Interface and hover over the Scripts input field. You'll see something like this:

Tooltip for scripts

Since we know from above that "PreferencesFilePaths" is represented by bpy.context.preferences.filepaths We simply add script_directory:


It is a string variable, but remember that in Python backslash is a string escape character, so if you're providing windows filepaths, you have to either use the 'r' form of a string (r"C:\tmp") or escape the backslashes ("C:\\tmp")

  • 1
    $\begingroup$ Wow, thank you very much! and thanks for the good explanation, this was very helpful. $\endgroup$
    – Jonas B.
    Feb 4, 2022 at 16:39
  • 2
    $\begingroup$ I tried different things but none of them worked to write the variable just to read it... But yours is working fine :) bpy.context.preferences.filepaths.script_directory = "C:\\tmp" And its just as simple as that, nice! $\endgroup$
    – Jonas B.
    Feb 4, 2022 at 16:45

Just posting a comment for anyone who stumbles on this post and is working with Blender 3.6+. Updates to the API mean that the user can now set multiple custom script directories and .script_directory has been deprecated in favour of .script_directories. The first directory path in that list (if set) can now be referenced with:


Alternatively you still reference the default scripts path with:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .