Hey, I’m walking through a directory to find a blend file, but I need to get all the collections it contains. Since it’s possible to go into the Collections folder it must be possible to list the contents
import bpy import os assetDir = "H:/Shared drives/Proj/2_PRO/Assets/Props/" section = "\\Collection\\" load = "Bench" for root, dirs, files in os.walk(assetDir): path = root.split(os.sep) for file in files: if file.endswith(".blend"): path = root + "/" +file directory = path + section filename = load try: bpy.ops.wm.link( filename=filename, directory=directory) except: pass
So this will check if the collection exists and link it in, but how can I list the contents.
Doing “os.listdir(directory)” will return a fileNotFound error.
It’s important to list the collections without linking them into the scene first.