Copy link to clipboard
Copied
I have this function that looks for a name of a comp and basically does a 'save comp as project' type operation. It works on the first item in my array but gets hung up somewhere after the alert where it says it's deleting layers. I can't figure out what the issue is. Help!
function runIt() {
app.beginUndoGroup("Make shots");
var nameMatchOrig = new Array();
var nameMatchNew = new Array();
var curProj = app.project.file;
if(!curProj){
var curProj = new File(dialog.btn_master.helpTip);
app.open(curProj);
}
var inputText = dialog.et_input.text.split(/\r?\n/);
alert(inputText.length + " shots to make");
var vfxComp = findItem("VFX SHOTS", false, "comp");
var keep = app.project.items.addFolder("KEEP");
for (var x = 0; x < inputText.length; x++) {
var curComp = findItem(inputText[x], false, "comp");
alert("attempting to delete all layers but " + curComp.name)
curComp.parentFolder = keep;
vfxComp.parentFolder = keep;
writeLn("Created folders");
app.project.reduceProject([curComp, vfxComp]);
var newfileInfo = dialog.btn_location.helpTip + "/" + curComp.name + "_v01.aep";
alert(newfileInfo);
keep.name = "Comps";
var newFile = new File(newfileInfo);
app.project.save(newFile);
app.open(curProj);
alert("Done with item " + x + " of " + inputText.length);
}
app.endUndoGroup();
}
Found the issue after days of trying.
These two lines needed to be inside the for loop. The loop included opening and closing the project so the variables got deleted in that process since they related to that certain project.
var vfxComp = findItem("VFX SHOTS", false, "comp");
var keep = app.project.items.addFolder("KEEP");
Copy link to clipboard
Copied
Found the issue after days of trying.
These two lines needed to be inside the for loop. The loop included opening and closing the project so the variables got deleted in that process since they related to that certain project.
var vfxComp = findItem("VFX SHOTS", false, "comp");
var keep = app.project.items.addFolder("KEEP");