I'd like to open a scene with certain mesh object and export it to FBX file from command line.
I read some related questions; importing and exporting via command line as per https://stackoverflow.com/questions/38096913/blender-convert-stl-to-obj-with-prompt-commande, then using tooltips to learn command as per How can I run blender from the command line to export and import models and using command console to pass arguments with file name with script to execute on loading How can I run blender from command line or a python script without opening a GUI?.
The goal in my case is to open certain .blend file and export the mesh object from there. The problem is that even though script works it looks like it performs actions not in expected order. The resulting FBX file I get contains startup scene (cube, camera and lamp) and according to the output from console it starts exporting scene first and reads blend last.
In order to export I use command:
blender.exe --background --python "D:\\Program Files\\fbx-export.py" "D:\\Program Files\\monkey.blend"
The python file contains:
import bpy
import sys
bpy.ops.export_scene.fbx(filepath='D:\\Program Files\\exported.fbx', axis_forward='-Z', axis_up='Y')
How to modify the command used so that it opens proper scene and exports the object correctly?