1 Reply Latest reply on Mar 25, 2008 2:10 PM by (Brett_Elliott)

    [JS][CS3] Delete duplicate contents within a group.

    Level 1
      Hi guys,

      I am having a tough time with this one.

      I have a group that has a dozen text frames in it. These text frames are populated by XML.

      My problem is when frame 1 contents match frame 2 contents I need to delete the contents of frame 1 (it will only ever be these two frames).

      I can do this easily enough when it is ungrouped with:

      var frameOne = app.documents[0].textFrames[9];
      var frameTwo = app.documents[0].textFrames[10];
      if (frameOne.contents == frameTwo.contents){
      frameOne.contents = "";

      Pretty basic but it works. When all the frames are grouped (needs to be unfortunately) this simple action eludes me. Does this have to be done at the xmlElements level? (if so I am having trouble there as well)

      I would appreciate any help with this problem.

        • 1. Re: [JS][CS3] Delete duplicate contents within a group.
          Level 1
          I couldn't find a solution to changing the contents within a group but I did make it work with a final function 'work around'.

          // Delete Duplicates
          function deleteDuplicates(){
          for (i=app.activeDocument.groups.length-1;i>=0;i--){
          var frameOne = pageTwo.textFrames.item("frameOne");
          var frameTwo = pageTwo.textFrames.item("frameTwo");
          if(frameOne.contents = frameTwo.contents){
          frameOne.contents = "";

          I would have preferred to keep everything grouped but doing this script as the last function solved my little problem. Still, if there is a way to do this without ungrouping I would appreciate any advice, thanks.