Basics of Blender's CLI (Command line interface)
The command line is definitely the way to go. Here is a little training that should be enough to get anyone up and running:
blender
Is the command to run Blender from the command line (you may need to setup an alias to have this on Mac or Linux).
blender -b
-b
is a flag that will run Blender in background mode. This is generally what you eventually want when rendering because it is generally faster. However, until you are confident with the command line, you may want to load the UI anyway, so that you can see what it's doing. To do so, simply omit the -b
flag. Note that to do the rest of these commands effectively, you must ensure that you have the -b
flag enabled.
blender -b filename.blend
Will open the file in the background, but still close immediately. This is not very useful, though, so we do something like this...
blender -b filename.blend -a
This will render out the animation as if you had opened the file and hit "Render Animation."
blender -b filename.blend -f framenumber
This will render out only the frame that was named, e.g.,
blender -b test.blend -f 10
will only render frame 10, then close.
Multi-file rendering
You can, however, string multiple files together. Suppose you are in a folder that has three blend files a.blend, b.blend, and c.blend. You want to render the 15th frame of a.blend, the entire b.blend animation, and the first frame of c.blend.
blender -b a.blend -f 15 b.blend -a c.blend -f 1
This command accomplishes this for us quite easily. Note that this is essentially the same thing as writing the following.
blender -b a.blend -f 15
blender -b b.blend -a
blender -b c.blend -f 1
In most command lines, you can also replace it with the following.
blender -b a.blend -f 15; blender -b b.blend -a; blender -b c.blend -f 1
Note that this is just the previous commands strung together on one line and separated by semicolons.
A bit about directories
There is something when using the command line called the current directory. You can change directory (the current directory) with the cd
command. The above assumes that all of the blend files are in the current directory which means that you can leave off the absolute file paths.
Suppose in the command above, we want to access three blend files that are on the desktop. We could cd
into the desktop (change the current directory to the desktop), so that the files can be accessed relative to that directory. On Unix systems (mostly Linux and MacOS), you could do something like this.
cd /Users/Username/Desktop/
The user's home directory has a shortcut ~
, so this is the same as the following.
cd ~/Desktop/
Default preferences for the terminal probably open it where the current directory is the user's home directory, so you can probably just do...
cd Desktop/
To see what is in the folder you are in, you can use...
ls # Mac/Linux
dir # Windows
To see the folder path...
pwd # Mac/Linux
cd # Windows (just use change directory without arguments)
The clunky way - absolute paths
That said, you could just use absolute paths and completely disregard the current directory stuff. I wanted to avoid showing this because of the difference between Unix and Window's ways of writing paths. Unix separates folders with /
and Windows separates folders with \
. I'll be showing the Unix style in this example. Note the use of the ~
...see above for what this means.
blender -b ~/Desktop/a.blend -f 15 ~/Documents/BlendFiles/b.blend -a /Users/Freddy/Desktop/c.blend -f 1
So if the Desktop
is in the Freddy
directory, a.blend
and c.blend
are both in the same folder.
Paths with spaces in them
One problem that you may encounter as Delagone mentioned in the comments is something like trying to navigate to:
/Users/Freddy/My Folder/
...where My Folder/
has a space in it. Because the command line separates arguments by spaces, you'll need to put double quotes around that argument to tell the command line to treat it all as one argument. For example, you could do something like the following.
cd "/Users/Freddy/My Folder"
This is one reason why most programmers tend to name folders without spaces; it makes it easier when working from the command line to navigate. Instead you can always name folders with camel-case MyFolder
or with underscores my_folder
.
If you are on a Unix-based system (I've not yet tested this on Windows), you can also escape the space and leave out the quotes. This is the default behavior for tab auto-completion on a Mac, while the quotes are default for Windows.
cd /Users/Freddy/My\ Folder/
The \
is the escape character and tells the command line to not interpret the next character in the usual way. In this case, it makes it treat it as a regular space character without separating them as arguments.