How to automate the conversion of objects generated by Python script to fbx or to obj?
The following script will allow to execute Blender in command line as so:

"&lt;your path to blender&gt;\blender.exe" --background --python exportFbx.py -- "&lt;your py file name&gt;" "&lt;your output directory&gt;"


Thanks to this answer and considering:


"exportFbx.py" is the file where the script below is saved into
the command line is run where the script is
"your py file name" is the complete name of one of your object generating .py scripts
"your output directory" is the directory where to store the exported result


The script, in short:


Get the arguments
Compose the output file name
clear the scene
execute your .py script
exports


Each part is commented below. Save it as "exportFbx.py".

import bpy
import sys
import ntpath

#Extracts file name from file path
def get_filename(path):
    path, name = ntpath.split(path)
    return name or ntpath.basename(path)

#Clears the scene
def delete_all():
    bpy.ops.object.delete({"selected_objects":[o for o in bpy.context.scene.objects]} )

#Executes a py file
def exec_py_file(filepath):
    file = open(filepath)
    exec(file.read())

#Gets command line arguments
def get_args():
    argv = sys.argv
    argv = argv[argv.index("--") + 1:] 
    return argv[0], argv[1]

#Obtain arguments
filepath, output_directory = get_args()

#Get the file name
filename = get_filename(filepath)

#Compose the fbx file name
output_filepath = ntpath.join( output_directory, filename + ".fbx")

#Clean the scene
delete_all()

#Run the py file
exec_py_file(filepath)

#Export to fbx
bpy.ops.export_scene.fbx(filepath=output_filepath, check_existing=False, use_selection=False, use_mesh_modifiers=True)


Now you'll have to iterate over your py file using your operating system commands in order to apply the command line above to all the .py file.

In Windows Powershell, that can be something like (not tested):

$files = Get-ChildItem "&lt;your path to py files\*.py"
foreach ($f in $files){
    $filename = $f.FullName
    "&lt;your path to blender&gt;\blender.exe" --background --python exportFbx.py -- "$filename" "&lt;your output directory&gt;"
} 


If you run:

"C:\Program Files\Blender Foundation\Blender 2.81\blender.exe" --background --python exportFbx.py -- "&lt;Essai.py&gt;" "C:\Users\user\Desktop\Bank2Son Zone Originale II\Command line"


That won't work. You need to have:

"[The path to blender.exe]" 
--background 
--python 
"[The path to exportFbx.py or just exportFbx.py if you run that in its directory]"
--
"[The path to one of your py file]"
"[The path to the output directory]"


Surely all what is inside "[]" above needs to be replaced by the good things as they are in your environment. And all that in one single line (I've separated things above for the explanation) with a space between each part.