Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created June 3, 2012 20:41
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 zeffii/2864967 to your computer and use it in GitHub Desktop.
Save zeffii/2864967 to your computer and use it in GitHub Desktop.
print .blend filenames inside directory
import bpy
import os
from os.path import join
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
# skip '.svn'
if dirpath.startswith("."):
continue
for filename in filenames:
filepath = join(dirpath, filename)
if filename_check is None or filename_check(filepath):
yield filepath
path_to_files = bpy.utils.script_paths()[0]
DIR = join(path_to_files, 'addons_contrib', 'io_material_loader')
source_files = []
source_files.extend(source_list(DIR, filename_check=lambda f: f.endswith(".blend")))
print("-"*40)
for i, filepath in enumerate(source_files):
# i want to print only the filename
file_name = filepath.split(os.sep)[-1]
print(file_name)
#print("TEST:", filepath, i, "of", len(source_files))
#with bpy.data.libraries.load(filepath) as (data_from, data_to):
# if data_from.masks:
# print("FOUND:", filepath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment