Reply To: Delete Empty (Anchor) frames

#85239
Ari Singer
Member

Try this out:

//Ari S. - designerjoe@outlook.com
// Delete empty anchored frames
app.scriptPreferences.enableRedraw = false;
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Delete Empty Anchored Frames");
function main(){
    var myDoc = app.activeDocument;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    app.findChangeGrepOptions.includeFootnotes = true;
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "~a";
    var myFound = myDoc.findGrep(true);
    for (i = (myFound.length - 1); i >= 0; i--){
        var myAnchorPosition = myFound[i];
        if (myAnchorPosition.texts[0].pageItems[0].contents == ""){
            myAnchorPosition.texts[0].pageItems[0].remove();
            }
        }
    }

This article was last modified on May 26, 2016

Comments (0)

Loading comments...