Free Function Friday Ep.24 – changeRenderPaths

March 04th 2016 08:00:47am

Welcome to the 23rd episode in the Free Function Friday series. Today we will create a function to batch change the render paths of items queued in your render queue. This function is very helpful if you are processing a lot of comps that then get queued and then rendered via a script, or if you simply just need to change the render path to a different folder. We’ll add an option to change only actively queued items, or all items in the render queue. This is a function I have used numerous times over the years at work.

Source Code:

var a = Folder("~/Desktop/TEST"); // Assumes a folder called "TEST" is located on the Desktop
alert(changeRenderPaths(a));
/*	TESTING ABOVE	*/

function changeRenderPaths(userSelectOrFolderObj){
	try{
	if(userSelectOrFolderObj instanceof Folder || userSelectOrFolderObj == true){
		var rq, itemTotal, slash, newLocation, curItem, curOM, oldLocation;
		rq = app.project.renderQueue;
		itemTotal = rq.numItems;
		$.os.indexOf("Windows") != (-1) ? slash = "\\" : slash= "/";
		if(userSelectOrFolderObj == true){
			newLocation = Folder.selectDialog("Select a folder to render to.");
		}else{
			newLocation = userSelectOrFolderObj;
		}
		if(newLocation instanceof Folder && newLocation.exists == true){
			for (i = 1; i <= itemTotal; ++i) {
				curItem = rq.item(i);
				if(curItem.status == RQItemStatus.QUEUED){
					for(j=1; j<=curItem.numOutputModules; ++j){
						curOM = curItem.outputModule(j);
						oldLocation = curOM.file;
						writeLn("Updating: "+ decodeURI(oldLocation.name));
						curOM.file = new File(newLocation.toString() + slash + oldLocation.name);
					}
				}
			}
			return File.decode(newLocation);
		}else{
			return null
		}
	}
	}catch(err){alert("Error at line #" + err.line.toString() + "\r" + err.toString());}
}
Checkout more:
Houdini Hotkeys
Free Function Friday Ep.3 – runMenuCmd
After Effects ExtendScript Training: Ep. 12 Part 1
Fix Broken X-Particles Cache
Free Function Friday Ep.9 – retrievePrimaryComps