How to export fbx to recent folder?

Hello, friends! I’m trying to export fbx file by my script but export window appears with picked blend file folder instead of last recent one. I can’t handle how to tell script to select recent folder. If somebody can help me I will be happy)

My script

class Retarget_OT_Export_Operator(bpy.types.Operator):
    """Export character to fbx"""
    bl_idname = "retarget.export_operator"
    bl_label = "EXPORT"


    def execute(self, context):

        #Define fbx name
        if animtrack.mute == 0:
            filename = rig.animation_data.nla_tracks["ANIM"].strips["ANIMATION"].action.name
        if animtrack.mute == 1:
            if rig.animation_data.action:
                filename = rig.animation_data.action.name
            else: filename = "!NO ANIM DATA!"

        char_mesh = bpy.data.collections['RETOP']
        for obj in char_mesh.objects:
            obj.select_set(True)
        bpy.ops.export_scene.fbx('INVOKE_DEFAULT', filepath=filename, use_selection=True, object_types={'ARMATURE', 'MESH'}, mesh_smooth_type= 'FACE', add_leaf_bones = False, use_armature_deform_only = True, bake_anim = True, bake_anim_use_all_bones = True, bake_anim_use_nla_strips = False, bake_anim_use_all_actions = False, bake_anim_force_startend_keying = False, bake_anim_step = 1.0, bake_anim_simplify_factor = 0.009999999776482582, path_mode = 'AUTO', embed_textures = False, batch_mode = 'OFF', use_batch_own_dir = True, axis_forward = '-Z', axis_up = 'Y')
       
        return {'FINISHED'}


def register():
    bpy.utils.register_class(Retarget_OT_Export_Operator)

def unregister():
    bpy.utils.unregister_class(VIEW3D_PT_export)

if __name__ == "__main__":
    register()

filename = <your_path> + rig.animation_data.action.name

Thank you for your answer! I need not defined path but last recent, how it works when fbx exporter used as usual. Folder destination sometime changing and I don’t want to change it in the script every time.
Here something useful but I am not so coder to attach it) https://docs.blender.org/api/2.93/bpy.types.SpaceFileBrowser.html#bpy.types.SpaceFileBrowser.recent_folders

bpy.types.SpaceFileBrowser.recent_folders[0]

should get the most recent folder, so you would use:

filename = bpy.types.SpaceFileBrowser.recent_folders[0] + rig.animation_data.action.name

Unfortunately :frowning:

Python: Traceback (most recent call last):
  File "/MyTools.py", line 191, in execute
AttributeError: type object 'SpaceFileBrowser' has no attribute 'recent_folders'

location: <unknown location>:-1

Try:

bpy.types.FileBrowserFSMenuEntry.recent_folders[0]
Python: Traceback (most recent call last):
  File "/ToshibaHDD/Projects/blender/Zakaz/Skinning/BSFG/Castanic/Castanic_Rigify.blend/MyTools.py", line 191, in execute
AttributeError: type object 'FileBrowserFSMenuEntry' has no attribute 'recent_folders'

location: <unknown location>:-1

Screenshot_20220623_222832
I found this but it’s not working and no error. I think the problem is filebrowser appears like temp window and my approaches just gone miss

try that with a [0] on the end

I did but…

Python: Traceback (most recent call last):
  File "/MyTools.py", line 191, in execute
TypeError: 'int' object is not subscriptable

location: <unknown location>:-1