2 Replies Latest reply on May 9, 2014 7:03 AM by Laubender

    Remove All Missing Links with frames

    HarveyLiu Level 1

      How can I make a script to remove all missing links with frames In indesign?

       

      var doc = app.activeDocument;
      var links = doc.links;

      for (var i = links.length-1; i >= 0; i--) {
      if (links[i].status == LinkStatus.LINK_MISSING) {
        try {
         links[i].parent.remove();
                   var image = link.parent;
                var frame = image.parent;
                frame.remove();
                counter++;

        }
        catch (err) {
         $.writeln(i + " - " + err);
        }
      }
      }

       

      I try this script, but still remain a frame, what's wrong with that?

        • 1. Re: Remove All Missing Links with frames
          Kasyan Servetsky Level 5

          This works for me:

          var link, image, frame,
          doc = app.activeDocument,
          links = doc.links,
          counter = 0;
          
          for (var i = links.length-1; i >= 0; i--) {
              if (links[i].status == LinkStatus.LINK_MISSING) {
                  try {
                      link = links[i];
                      image = link.parent;
                      frame = image.parent;
                      frame.remove();
                      counter++;
                  }
                  catch (err) {
                      $.writeln(i + " - " + err);
                  }
              }
          }
          
          • 2. Re: Remove All Missing Links with frames
            Laubender Adobe Community Professional & MVP

            @Harvey – in priciple nothing's wrong with that.

             

            But you need only to remove the parent.parent of the found link.

             

            You could also resolve the object that is behind parent.parent to make sure it will work:

             

            var myContainerToRemove = links[i].parent.parent.getElements()[0];
            myContainerToRemove.remove();
            

             

            No container, no image, no link ;-)

             

            Of course that will leave a container frame behind, if the container of the graphic is itself nested into another object.

            This could be a Texts object (together with a text frame) or a SplineObject like a Rectangle, Oval, Polygon, a Button as well as a State inside an MSO…

             

            A remnant could also be a Group object containing only one page item…
            Depends on how the page items are used and the layout is constructed.

             

            Uwe