Does running a python script via Blender command line not actually do anything? I am trying to create an animation programmatically (never using the interface) with Blender.  I can take my script and run it in Blender via the "scripts" tab just fine. It creates new scenes, adds cameras, object, lights, etc.  I can render the results of the script via the GUI or via command line.  But when I run it from the command line, it doesn't actually do anything!

I am using a "blank" .blend file with one initial scene in it with a title card.

Here is the .bat file script (Windows), it uses a python script to create the animation file:

cd\program files\blender foundation\blender
blender --background  C:\pathtofile\ANIMATION.blend --python CREATE_ANIMATION_FILE.py


It gives me:

found bundled python: C:\Program Files\Blender Foundation\Blender\2.78\python
read blend: C:\pathtofile\ANIMATION.blend 

Blender quit


It runs the script just fine but doesn't change the ANIMATION.blend file at all. Again, if I run the script from the scripts window via the in Blender GUI, it works fine.  Anyone come across this?

I found some info here:


  11) Next step is to build a userpref.blend with Auto Run Python
  Scripts enabled. NOTE: This is essential because of a bug in blender.
  Starting blender with -y does not work. Neither does starting blender
  with a python script setting the autorun flag to ON. It even does not
  work to compile blender yourself with the WITH_PYTHON_SECURITY flag
  disabled (OFF). Blender will still not execute the python script. The
  only way to enable this auto execute is via the GUI. Since we do not
  have a GUI (or want to install one), we have to build a userpref.blend
  on a different machine.
David above solved it.   When manipulating a .blend file with a python script, that script must contain the following line at the end of the run in order to save the file:

bpy.ops.wm.save_as_mainfile(filepath=savepath)


Obviously insert your filepath/filename in the "filepath" variable. Thanks!