Full Script
I just tested with a simple animation of a rotating cube. It works.
# GPL 2 or any later version
import sys
args = sys.argv # This is the list of the arguments you have passed to it
# Let's save them for clarity
blendfile = args[1]
destination = args[2]
imageformat = args[3]
startframe = args[4]
endframe = args[5]
def getnumstr(num):
# This function turns numbers like 1 or 20 into numbers like 0001 or 0020
s = ""
for i in range(4-len(str(num))):
s = s + "0"
return s+str(num)
def getfileoutput(num, FORMAT):
# Function gives an output of a file. From the current frame that's rendering.
# instead of having frame 1 and format EXR it will give you 0001.exr
s = getnumstr(num) # Here I'm using the previously defined function
if FORMAT == "JPEG":
s = s + ".jpg"
else:
s = s + "." + FORMAT.lower()
return s
import os # A module that can output list of files in a folder
# And can run commands in the terminal
while True: # Spawns up a never ending loop.
# We need a mechanism to stop the script when it's done rendering
tostop = True
# Checking if the file is in the folder
for framenumber in range( int( startframe ), int( endframe )):
imagefilename = getfileoutput( framenumber, imageformat )
if imagefilename not in os.listdir( destination ):
tostop = False # If at least one frame missing, we do not stop.
# Lets render the picture
os.system("blender -b "+blendfile+" -o "+destination+"/#### -F "+imageformat+" -f "+str(framenumber))