Skip to content

Instantly share code, notes, and snippets.

@CGArtPython
Created March 21, 2023 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CGArtPython/0c0ab7f777ef74b1d8e5364f965cd3e9 to your computer and use it in GitHub Desktop.
Save CGArtPython/0c0ab7f777ef74b1d8e5364f965cd3e9 to your computer and use it in GitHub Desktop.
[Blender Python Scripting] Get a list of blend file in the same folder as the Python script file
import pathlib
import pprint
path_to_current_dir = pathlib.Path(__file__).parent
###########
# Option 1
###########
blend_files = list()
for blend_file in path_to_current_dir.glob("*.blend"):
blend_files.append(str(blend_file))
###########
# Option 2
###########
# you can also create a list in one line like this
# blend_files = [str(blend_file) for blend_file in path_to_current_dir.glob("*.blend")]
pprint.pprint(blend_files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment