I want to check all the subfolder in the selected folder in the blender and import the fbx in it. And I want to apply the file name of the imported model to the obj example: file name: Model.fbx but in fbx object is cube. By default, blender applies this name to the imported object: cube. But I want the name of the imported object must be Model. I think I could explain.
Import fbx from all subfolders. Apply its own file name for each model
my try:
def importer(path, name):
bpy.ops.import_scene.fbx(filepath=path)
for obj in bpy.context.selected_objects:
obj.name = name
def dirScan(dirs, path):
for c in dirs:
if os.path.isdir(path+c):
tempd = os.listdir(path+c+'/')
for c1 in tempd:
if os.path.isfile(path+c+'/'+c1):
if os.path.splitext(c1)[1] == ".fbx":
importer(path+c+'/'+c1, os.path.splitext(c1)[0])
else:
dirScan(os.listdir(path+c+'/'+c1))
else:
if os.path.splitext(c)[1] == ".fbx":
importer(path+c, os.path.splitext(c)[0])