I released ealier the FBX Bundle addon which is free and open
With the specified path the script imports any obj, 3ds or fbx files into the scene
The relevant code snippet
def import_files(path):
# https://blender.stackexchange.com/questions/5064/how-to-batch-import-wavefront-obj-files
# http://ricardolovelace.com/batch-import-and-export-obj-files-in-blender.html
path = bpy.path.abspath(path)
extensions = ['fbx', 'obj', '3ds']
filenames = sorted(os.listdir(path))
filenames_valid = []
for filename in filenames:
for ext in extensions:
if filename.lower().endswith('.{}'.format(ext)):
filenames_valid.append(filename)
break
for name in filenames_valid:
file_path = os.path.join(path, name)
extension = (os.path.splitext(file_path)[1])[1:].lower()
print("- {} = {}".format(extension, file_path))
# https://docs.blender.org/api/2.78a/bpy.ops.import_scene.html
if extension == 'fbx':
if hasattr(bpy.types, bpy.ops.import_scene.fbx.idname()):
bpy.ops.import_scene.fbx(filepath = file_path)
elif extension == 'obj':
if hasattr(bpy.types, bpy.ops.import_scene.obj.idname()):
bpy.ops.import_scene.obj(filepath = file_path)
elif extension == '3ds':
if hasattr(bpy.types, bpy.ops.import_scene.autodesk_3ds.idname()):
bpy.ops.import_scene.autodesk_3ds(filepath = file_path)
Feel free to copy and improve