Page 1 of 1

Mass "Remove Masks" script?

Posted: August 11th, 2016, 11:06 am
by Navstar
Since there isn't a keyboard shortcut for Remove Mask, anyone know of a script that can remove all Masks from selected layers?

I've inherited a messy comp with lots duplicated layers that have many unused masks.

Re: Mass "Remove Masks" script?

Posted: August 11th, 2016, 1:49 pm
by beginUndoGroup
You can try this, it removes all masks blindly (save as .jsx in the ScriptUIPanel folder, restart AE, then launch from the Window menu):

Code: Select all

this.add("button{text: 'remove all masks'}").onClick = function(){
    var comp = app.project.activeItem;
    if (!comp || comp.typeName !== "Composition" || comp.selectedLayers.length<1){
        alert("No layer selected");
        }
    else{
        var sel = comp.selectedLayers, N=sel.length, n, layer, numMasks;
        var removed = 0;
        app.beginUndoGroup("Remove All Masks");
        for (n=0; n<N; n++){
            layer = sel[n];
            if (!layer.mask) continue;
            numMasks = layer.mask.numProperties;
            removed += numMasks;
            while (numMasks>0) layer.mask(numMasks--).remove();
            };
        app.endUndoGroup();
        alert("Removed " + removed + " masks on " + N + " layers");
        };
    };
this.layout.layout(true);

Xavier

Re: Mass "Remove Masks" script?

Posted: August 20th, 2016, 1:32 am
by zold
You can also use my much-neglected "Mask Selection Helper" script on crgreen.com. It allows you to select all or some masks based on index or name matching. After selecting, you have to close the script window, then hit delete and the selected masks (even if they're not revealed) are deleted.