As far as I know, and I get this from Command Line Arguments — Blender Manual, there is no way to do this only with command lines. Blender's command line usage is limited to headless rendering and some debugging for developpers.
However, there is the argument -P
(uppercase!) which allows you to run a python script. So theoretically, if you have a python script that does the data packing, then saving, then rendering, it might work.
So, considering in my case I am working from myfile.blend
, let's create a simple python script pack-and-save.py
in the same folder:
import bpy
bpy.ops.file.pack_all()
myPath = bpy.data.filepath
myPath = str(myPath)
bpy.ops.wm.save_as_mainfile(filepath=myPath[:-6]+'_packed'+myPath[-6:])
It simply packs data inside the current file, then save it with the suffix "_patcked".
- If you don't want to save as a different file, you can remove
[:-6]+'_packed'+myPath[-6:]
in the last line.
- You can compress the newly created file, this will make your file lighter on your disk but at the cost of I/O times and ressource usage. Simply add
,compress=True
before the closing )
in the last line.
To use this script, open a command line in the same folder and run the following command:
blender -b "myfile.blend" -P pack-and-save.py
That will effectively run a headless Blender, open myfile.blend
, execute pack-and-save.py
and close. Which results into the creation of a myfile_packed.blend
file with all your data packed inside.
Once this is done, you can use this command line to run the rendering itself:
blender -b "myfile_packed.blend" -a
To make both the packing and rendering in one go, you can combine the two command lines using the "double ampersand" conditional execution &&
like so:
blender -b "myfile.blend" -P pack-and-save.py && blender -b "myfile_packed.blend" -a
It is better to use a double ampersand instead of a single one, so that the render is run only if the packaging was done successfully.
Note that the command line I used for rendering doesn't specify any rendering setting nor file output, it simply does what you have set in your file.
For further reading, see Command Line Rendering — Blender Manual.