• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Loop won't continue

Explorer ,
Sep 20, 2022 Sep 20, 2022

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();
}
TOPICS
Scripting

Views

113

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Sep 21, 2022 Sep 21, 2022

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");

Votes

Translate

Translate
Explorer ,
Sep 21, 2022 Sep 21, 2022

Copy link to clipboard

Copied

LATEST

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");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines