Script to export gltf fails with 'Context' object has no attribute 'active_object'
Creating a fake active object attribute on the context and passing it to the operator should work. Try this:
CONVERT_DIR = &quot;my/dir&quot;

import os

def file_iter(path, ext):
    for dirpath, dirnames, filenames in os.walk(path):
        for filename in filenames:
            ext = os.path.splitext(filename)[1]
            if ext.lower().endswith(ext):
                yield os.path.join(dirpath, filename)

import bpy


def reset_blend():
    bpy.ops.wm.read_factory_settings(use_empty=True)

def convert_recursive(base_path):
    for filepath_src in file_iter(base_path, &quot;.fbx&quot;):
        filepath_dst = os.path.splitext(filepath_src)[0] + &quot;.glb&quot;

        print(&quot;Converting %r -&gt; %r&quot; % (filepath_src, filepath_dst))

        reset_blend()

        bpy.ops.import_scene.fbx(filepath=filepath_src)
        
        # create a copy of the context
        ctx = bpy.context.copy()
        
        # because the active_object attribute isn't created until the user interacts
        # with the scene we create one here but we don't need to set it to anything
        ctx['active_object'] = None

        # pass our context copy with active object attribute to the operator
        bpy.ops.export_scene.gltf(ctx, export_format=&quot;GLB&quot;,filepath=filepath_dst)


if __name__ == &quot;__main__&quot;:
    convert_recursive(CONVERT_DIR)