// Rerender last item in Render Queue
// Redoes the most recent render directly atop
// the same file and everything.

var lastIndex = app.project.renderQueue.numItems;
var renderQueueItem = null;
if(lastIndex > 0)
{
    // suggested by Dan Ebberts -- do it the hard way
    // since "duplicate()" seems to leave the item "already done".
    // just make sure we get all the fields...

    var renderQueueItem = app.project.renderQueue.item(lastIndex);   
    var myRQItem = app.project.renderQueue.items.add(renderQueueItem.comp); 
    myRQItem.applyTemplate(renderQueueItem.templates[0]); 
    var OM = renderQueueItem.outputModule(1); 
    var myOM = myRQItem.outputModule(1); 
    myOM.file = OM.file; 
    myOM.postRenderAction = OM.postRenderAction; 
    myOM.applyTemplate(OM.name); 
    myRQItem.timeSpanStart = renderQueueItem.timeSpanStart; 
    myRQItem.timeSpanDuration = renderQueueItem.timeSpanDuration; 
    app.project.renderQueue.render(); 
}  
else
{
    alert("No items in Render Queue");
}


// EOF
