Execute export maya animation clips in gameExporter script

Hello! I want to create a script (MEL or Python doesn’t matter) only to execute the export after setting the animation lenghts and names and export directory by myself. I cant seem to find how and I could use some help. Thank you!

Hope this helps:

import maya.cmds as cmds

def export_animation(start_frame, end_frame, export_dir, file_name):
    # Set the start and end frames
    cmds.playbackOptions(min=start_frame, max=end_frame)
    # Create the full file path. change the format here too
    file_path = os.path.join(export_dir, file_name + ".ma")
    # list obj selected in viewport
    selected_obj = cmds.ls(sl=True)
    # Select all objects for export
    cmds.select(selected_obj)
    # Export selected objects to the file path. you can change the format here
    cmds.file(file_path, force=True, options="v=0;", type="mayaAscii", exportSelected=True)


start_frame = 1
end_frame = 120
export_dir = #"C:/path/to/export/directory"
file_name = "enter_animation_name"

export_animation(start_frame, end_frame, export_dir, file_name)