I am using this command line:

blender -P test.py test.blend

and test.py has:

import bpy
for scene in bpy.data.scenes:
    scene.render.image_settings.file_format = "FFMPEG"

If I run with just this command line:

blender -P test.py

the file format is set just fine. But if I put the blender file back in the command line, the file format is not changed. My interpretation is that the .py file is run before the .blend file is loaded. Whether or not my interpretation is correct, how can I make this happen the way I want it to?

Additional information: This is a stand-along render server for high school students and I need to ensure that a number of things are set correctly and not just the file format.


Command line arguments are run in the order they are given. So at the minute, yes, the Python file is being run and then the 'test.blend' file is being opened.

To fix this you just need to put the blend file part of the command first and the Python file after:

blender test.blend -P test.py

Now your file is opened then the Python commands are run in that opened file.

  • $\begingroup$ Dang! It was that simple? Yep, your solution works! Thanks!!!! $\endgroup$ – Stew King Dec 1 '17 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.