Export FBX with full collection hierarchy
import bpy

sCollection = bpy.context.collection

def parentCol(_colParent, _objParent):
    for col in _colParent.children:
        newObj = bpy.data.objects.new(&quot;empty&quot;, None)
        bpy.context.scene.collection.objects.link(newObj)
        newObj.name = col.name
        newObj.parent = _objParent
    
        if len(col.objects) &gt; 0:
            objs = col.objects
            for obj in objs:
                obj.parent = newObj
        else:
            parentCol(col, newObj)
                
root = bpy.data.objects.new(&quot;empty&quot;, None)
bpy.context.scene.collection.objects.link(root)
root.name = sCollection.name

parentCol(sCollection, root)

The script is originally from this question. Since I see you spotted the script as working for you I wanted to flag your question as duplication, but system doesn't allowing me to do that. For that I copy&amp;pasted the script here as answer. So you can accept it here if this solved your needs.