How to batch convert between file formats? I have about thousands of files I need to convert into from one format to another. Both formats are handled by existing add-ons..

I assume the script process would go something like this:


Select every source file in a directory and it's sub-directories
Store the path and filename of the source format.
Delete everything in scene and import the file
Export the file to the destination format with the same path and the same filename as the original file, with a different extension.
move on to the next item


The problem is that I have very little experience with Blender, and Python is not my area. The manual solution of importing and exporting works perfectly fine, as there is no need for anything to be modified.
Set the path variable and change the import line to whatever importer you are using :

import bpy
import os

path = 'C:/path/to/files/'  # set this path

for root, dirs, files in os.walk(path):
    for f in files:
        if f.endswith('.meshdata') :
            mesh_file = os.path.join(path, f)
            obj_file = os.path.splitext(mesh_file)[0] + ".obj"

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

            bpy.ops.import_scene.obj(filepath=mesh_file) # change this line

            bpy.ops.object.select_all(action='SELECT')

            bpy.ops.export_scene.obj(filepath=obj_file)