Path Utilities (bpy.path)

This module has a similar scope to os.path, containing utility functions for dealing with paths in Blender.

bpy.path.abspath(path, start=None)

Returns the absolute path relative to the current blend file using the “//” prefix.

Parameters:start (string) – Relative to this path, when not set the current filename is used.
bpy.path.clean_name(name, replace='_')

Returns a name with characters replaced that may cause problems under various circumstances, such as writing to a file. All characters besides A-Z/a-z, 0-9 are replaced with “_” or the replace argument if defined.

bpy.path.display_name(name)

Creates a display string from name to be used menus and the user interface. Capitalize the first letter in all lowercase names, mixed case names are kept as is. Intended for use with filenames and module names.

bpy.path.display_name_from_filepath(name)

Returns the path stripped of directort and extension, ensured to be utf8 compatible.

bpy.path.ensure_ext(filepath, ext, case_sensitive=False)

Return the path with the extension added its its not alredy set.

Parameters:
  • ext (string) – The extension to check for.
  • case_sensitive (bool) – Check for matching case when comparing extensions.
bpy.path.is_subdir(path, directory)

Returns true if path in a subdirectory of directory. Both paths must be absolute.

bpy.path.module_names(path, recursive=False)

Return a list of modules which can be imported from path.

Parameters:
  • path (string) – a directory to scan.
  • recursive (bool) – Also return submodule names for packages.
Returns:

a list of string pairs (module_name, module_file).

Return type:

list

bpy.path.relpath(path, start=None)

Returns the path relative to the current blend file using the “//” prefix.

Parameters:start (string) – Relative to this path, when not set the current filename is used.
bpy.path.resolve_ncase(path)

Resolve a case insensitive path on a case sensitive system, returning a string with the path if found else return the original path.

Previous topic

Utilities (bpy.utils)

Next topic

Application Data (bpy.app)