How do I batch import one format, then export to another? I'm hoping this question builds on a previous question, Batch import Wavefront OBJ.

I'd like to batch import a bunch of .3ds files and export each of them to their own .js file (using the Three.js file importer/exporter addon). Is there a way to do this in Python? If so, how would I do this? I have 77 files to convert, so it wouldn't kill me to do it by hand, but I'd rather not.

Or should I find a non-Blender solution? There is an online tool called Online 3D Model Converter. Unfortunately, the exports from this tool are not nearly as clean and small as those from Blender.
Here is an outline:


Make sure 3DS importer and Three.js exporter are installed and enabled

# test
hasattr(bpy.types, "EXPORT_OT_threejs")

# enable
try:
    bpy.ops.wm.addon_enable(module="threejs")
except ImportError:
    print("Threejs importer addon not available")

Loop over all the files and perform below actions for every single one,
you may use glob.glob() or os.walk() unless you want to select the files via UI
(see the Operator Import tempate, you will need to provide
files = bpy.props.CollectionProperty(type=bpy.types.PropertyGroup), docs)
Clear scene if desired, e.g.

 bpy.ops.object.mode_set(mode='OBJECT')
 bpy.ops.object.select_all(action='SELECT')
 bpy.ops.object.delete()

Import 3DS, basically call the operator bpy.ops.import_scene.autodesk_3ds(filepath="the_path_to_file.3ds")
The importer should select the imported files, but there will usually not be an active object. To run operations on the imported data or for some exporters you might need to set one object active (or process each individually and make one active after another).
Export to JS, basically call the operator bpy.ops.export.threejs(filepath="target_file.js", **kwargs),
kwargs stands for all additional arguments you may wanna give to the export operator.