11 Replies Latest reply on Oct 17, 2017 12:48 AM by Sleem

    Please provide the Story Splitter script by Adi Ravid?

    Jaxiter Level 1

      Hi,

       

      I'm working on a complex book and need to split threaded stories at lots of places. I know I can do it manually through the Story Editor but have really set my eyes on the Story Splitter script created by Adi Ravid. I found its place @ the Adobe Exchange (http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1302 518#)  but get an error "We're sorry, we encountered an error processing your request." - also when pressing "Email author: Adi Ravid".

       

      So, could someone who has the script please post it here?

       

      Thanks a lot in advance

        • 1. Re: Please provide the Story Splitter script by Adi Ravid?
          Sumit_Garg Adobe Employee

          /*

          ------------------------------------------------------------------------------------------ ------------------------

          StorySplitter

          ------------------------------------------------------------------------------------------ ------------------------

          An InDesign CS/CS2/CS3 JavaScript by FourAces

          © The Final Touch 2006

          Version 3.0.0

           

           

          Splits the selected Story to separate Text Frames, while maintaining their contents.

          ------------------------------------------------------------------------------------------ ------------------------

          */

          var myScriptVer = "3.0";

           

           

          if(app.documents.length != 0){

                    var mySelection = app.activeDocument.selection;

                    if(mySelection.length != 0){

                              myObjectType = mySelection[0].constructor.name;

                              if(myObjectType == "TextFrame"){

                                        //The Interface Dialog

                                        var myDialog = app.dialogs.add({name:"Story Splitter v"+ myScriptVer});

                                        with(myDialog){

                                                  with(dialogColumns.add()){

                                                            with (dialogRows.add()){

                                                                      with(borderPanels.add()){

                                                                                var mySplitOptions = radiobuttonGroups.add();

                                                                                with(mySplitOptions){

                                                                                          radiobuttonControls.add({staticLabel:"Split All Frames", checkedState:true});

                                                                                          radiobuttonControls.add({staticLabel:"Split Before Selected Frame"});

                                                                                          radiobuttonControls.add({staticLabel:"Split After Selected Frame"});

                                                                                }

                                                                      }

                                                            }

                                                            with (dialogRows.add()){

                                                                      staticTexts.add({staticLabel:"© The Final Touch"});

                                                            }

                                                  }

                                        }

                                        var myResult = myDialog.show({name:"SplitOptions"});

                                        if(myResult == true){

                                                  var myStory = mySelection[0].parentStory;

                                                  if(app.version.split(".")[0] >= 5){

                                                            var myTextFrames = myStory.textContainers;

                                                  }

                                                  else{

                                                            var myTextFrames = myStory.textFrames;

                                                  }

                                                  var myStoryFramesCount = myTextFrames.length;

                                                  if(myStoryFramesCount > 1){

                                                            for(f = 0; f < myStoryFramesCount; f++){

                                                                      if (mySelection[0] == myStory.textFrames[f]){

                                                                                var myTextFrame = f;

                                                                      }

                                                            }

                                                            switch(mySplitOptions.selectedButton){

                                                                      case 0:

                                                                                mySplitAll();

                                                                                break;

                                                                      case 1:

                                                                                mySplitBefore();

                                                                                break;

                                                                      case 2:

                                                                                mySplitAfter();

                                                                                break;

                                                            }

                                                  }

                                                  else{

                                                            alert("Are You Kidding Me?!\nThe Story you selected has only ONE text frame.");

                                                  }

                                        }

                              }

                              else{

                                        alert("Wrong Selection\nYou selected the wrong type of object. Please select a Text Frame.");

                              }

                    }

                    else{

                              alert("No Selection Made.\nPlease select a Story to split.");

                    }

          }

          else{

                    alert("No Active Document Found.\nPlease open an InDesign document and select a Story to split.");

          }

           

           

          //----------------------------------------------------------------------------

          function mySplitAll(){

                    for(i = 0; i < myStoryFramesCount; i++){

                              myTextFrames[i].duplicate();

                    }

                    for(i = 0; i < myStoryFramesCount; i++){

                              if(app.version.split(".")[0] >= 5){

                                        myTextFrames[i].remove();

                              }

                              else{

                                        myTextFrames[0].remove();

                              }

                    }

          }

           

           

          function mySplitBefore(){

                    if(mySelection[0].previousTextFrame == null){

                              alert("Unable Break Thread.\nThe selected Text Frame is the FIRST text frame of the thread.");

                    }

                    else{

                              var myBfBreakFrame = mySelection[0].previousTextFrame;

                              var myAfBreakFrame = mySelection[0];

                              var myBreakStory = myBfBreakFrame.parentStory;

                              mySelection[0].previousTextFrame = null;

                              if(myBfBreakFrame.overflows == true){

                                        var myOversetText = myBreakStory.texts.itemByRange(myBfBreakFrame.insertionPoints[-1],myBreakStory.insertionP oints[-1]);

                                        myOversetText.select();

                                        app.cut();

                                        app.select(myAfBreakFrame.insertionPoints[0]);

                                        app.paste();

                              }

                    }

          }

           

           

          function mySplitAfter(){

                    if(mySelection[0].nextTextFrame == null){

                              alert("Unable Break Thread.\nThe selected Text Frame is the LAST text frame of the thread.");

                    }

                    else{

                              var myBfBreakFrame = mySelection[0];

                              var myAfBreakFrame = mySelection[0].nextTextFrame;

                              var myBreakStory = myBfBreakFrame.parentStory;

                              mySelection[0]          .nextTextFrame = null;

                              if(myBfBreakFrame.overflows == true){

                                                  var myOversetText = myBreakStory.texts.itemByRange(myBfBreakFrame.insertionPoints[-1],myBreakStory.insertionP oints[-1]);

                                        myOversetText.select();

                                        app.cut();

                                        app.select(myAfBreakFrame.insertionPoints[0]);

                                        app.paste();

           

                              }

                    }

          }

          1 person found this helpful
          • 2. Re: Please provide the Story Splitter script by Adi Ravid?
            Jaxiter Level 1

            Thanks a lot for posting the script!

             

            However, it gives the following error, as it appears when creating the dialog box:

             

             

            ---------------------------

            Adobe InDesign

            ---------------------------

            JavaScript Error!

             

             

            Error Number: 25

            Error String: Expected: :

             

             

            Engine: main

            File: C:\Users\MYPC\AppData\Roaming\Adobe\InDesign\Version 8.0-ME\en_AE\Scripts\Scripts Panel\StorySplitter.js

            Line: 29

            Source: radiobuttonControls.add({stat icLabel:"Split All Frames", checkedState:true});

            Offending Text: icLabel

             

             

            Someone who could help me out please?

            • 3. Re: Please provide the Story Splitter script by Adi Ravid?
              Jump_Over Level 5

              Hi,

               

              Copy...paste source code more accurate (watch spaces at line ends):

               

              i.e.

              radiobuttonControls.add({stat icLabel:"Split All Frames", checkedState:true});

               

              suppose to be:

              radiobuttonControls.add({staticLabel:"Split All Frames", checkedState:true});

               

              Jarek

              1 person found this helpful
              • 4. Re: Please provide the Story Splitter script by Adi Ravid?
                Jaxiter Level 1

                Hi Jump_Over,

                 

                Hmm indeed, thanks for spotting that Nnow that I look at the code above there seem to be more spaces breaking up things - I'll try to find and remove them.

                 

                Thanks again

                1 person found this helpful
                • 5. Re: Please provide the Story Splitter script by Adi Ravid?
                  [Jongware] Most Valuable Participant

                  Jaxiter, is this not the same script that appears as "SplitStory.jsx" in the Application->Samples->Javascript folder in the Script Panel? Its header reads

                   

                  //Splits the selected story into separate (i.e., unthreaded) text frames.

                  //To use this script, select a text frame, then run the script.

                   

                  but carries no actual reference to Adi.

                  • 6. Re: Please provide the Story Splitter script by Adi Ravid?
                    Jaxiter Level 1

                    Hi Jongware,

                     

                    Thanks for your reply


                    The script that I was after was indeed the one posted by Sumit_Garg, which I was able to get working after the comment of Jump_Over - sorry was so caught up in finishing the job that I wasn't able to get back to reply that it was solved after I removed the spaces that broke it.

                     

                    The script 'SplitStory' provided with Indesign that you are revering to splits the story up the seperate text frames that it consists of while with the script by Adi Ravid (a.k.a. FourAces as it seems) 'StorySplitter' you can select if you want to

                     

                    1. Split all text frames (like 'SplitStory');
                    2. Split before selected text frame;
                    3. Split after selected text frame.

                     

                    So with option 2 or 3 you can split the selected story at the selected text frame.

                     

                    As I wanted to cut up a big Word file that I had imported at the chapters, it was very helpfull instead of selecting all text that would overset, cut it, unthread the frame and then paste it again in the next page - and that for each chapter. And with a file that was already instable as it was...

                     

                     

                    For completeness sake, here's the corrected script:

                     

                    /*

                    ---------------------------------------------------------------------- --------------------------------------------

                    StorySplitter

                    ---------------------------------------------------------------------- --------------------------------------------

                    An InDesign CS/CS2/CS3 JavaScript by FourAces

                    © The Final Touch 2006

                    Version 3.0.0

                     

                     

                    Splits the selected Story to separate Text Frames, while maintaining their contents.

                    ---------------------------------------------------------------------- --------------------------------------------

                    */

                    var myScriptVer = "3.0";

                     

                     

                    if(app.documents.length != 0){

                              var mySelection = app.activeDocument.selection;

                              if(mySelection.length != 0){

                                        myObjectType = mySelection[0].constructor.name;

                                        if(myObjectType == "TextFrame"){

                                                  //The Interface Dialog

                                                  var myDialog = app.dialogs.add({name:"Story Splitter v"+ myScriptVer});

                                                  with(myDialog){

                                                            with(dialogColumns.add()){

                                                                      with (dialogRows.add()){

                                                                                with(borderPanels.add()){

                                                                                          var mySplitOptions = radiobuttonGroups.add();

                                                                                          with(mySplitOptions){

                                                                                                    radiobuttonControls.add({staticLabel:"Split All Frames", checkedState:true});

                                                                                                    radiobuttonControls.add({staticLabel:"Split Before Selected Frame"});

                                                                                                    radiobuttonControls.add({staticLabel:"Split After Selected Frame"});

                                                                                          }

                                                                                }

                                                                      }

                                                                      with (dialogRows.add()){

                                                                                staticTexts.add({staticLabel:"© The Final Touch"});

                                                                      }

                                                            }

                                                  }

                                                  var myResult = myDialog.show({name:"SplitOptions"});

                                                  if(myResult == true){

                                                            var myStory = mySelection[0].parentStory;

                                                            if(app.version.split(".")[0] >= 5){

                                                                      var myTextFrames = myStory.textContainers;

                                                            }

                                                            else{

                                                                      var myTextFrames = myStory.textFrames;

                                                            }

                                                            var myStoryFramesCount = myTextFrames.length;

                                                            if(myStoryFramesCount > 1){

                                                                      for(f = 0; f < myStoryFramesCount; f++){

                                                                                if (mySelection[0] == myStory.textFrames[f]){

                                                                                          var myTextFrame = f;

                                                                                }

                                                                      }

                                                                      switch(mySplitOptions.selectedButton){

                                                                                case 0:

                                                                                          mySplitAll();

                                                                                          break;

                                                                                case 1:

                                                                                          mySplitBefore();

                                                                                          break;

                                                                                case 2:

                                                                                          mySplitAfter();

                                                                                          break;

                                                                      }

                                                            }

                                                            else{

                                                                      alert("Are You Kidding Me?!\nThe Story you selected has only ONE text frame.");

                                                            }

                                                  }

                                        }

                                        else{

                                                  alert("Wrong Selection\nYou selected the wrong type of object. Please select a Text Frame.");

                                        }

                              }

                              else{

                                        alert("No Selection Made.\nPlease select a Story to split.");

                              }

                    }

                    else{

                              alert("No Active Document Found.\nPlease open an InDesign document and select a Story to split.");

                    }

                     

                     

                    //-------------------------------------------------------------------- --------

                    function mySplitAll(){

                              for(i = 0; i < myStoryFramesCount; i++){

                                        myTextFrames[i].duplicate();

                              }

                              for(i = 0; i < myStoryFramesCount; i++){

                                        if(app.version.split(".")[0] >= 5){

                                                  myTextFrames[i].remove();

                                        }

                                        else{

                                                  myTextFrames[0].remove();

                                        }

                              }

                    }

                     

                     

                    function mySplitBefore(){

                              if(mySelection[0].previousTextFrame == null){

                                        alert("Unable to break thread.\nThe selected Text Frame is the FIRST text frame of the thread.");

                              }

                              else{

                                        var myBfBreakFrame = mySelection[0].previousTextFrame;

                                        var myAfBreakFrame = mySelection[0];

                                        var myBreakStory = myBfBreakFrame.parentStory;

                                        mySelection[0].previousTextFrame = null;

                                        if(myBfBreakFrame.overflows == true){

                                                  var myOversetText = myBreakStory.texts.itemByRange(myBfBreakFrame.insertionPoints[-1],myBreakStory.insertionP oints[-1]);

                                                  myOversetText.select();

                                                  app.cut();

                                                  app.select(myAfBreakFrame.insertionPoints[0]);

                                                  app.paste();

                                        }

                              }

                    }

                     

                     

                    function mySplitAfter(){

                              if(mySelection[0].nextTextFrame == null){

                                        alert("Unable Break Thread.\nThe selected Text Frame is the LAST text frame of the thread.");

                              }

                              else{

                                        var myBfBreakFrame = mySelection[0];

                                        var myAfBreakFrame = mySelection[0].nextTextFrame;

                                        var myBreakStory = myBfBreakFrame.parentStory;

                                        mySelection[0].nextTextFrame = null;

                                        if(myBfBreakFrame.overflows == true){

                                                   var myOversetText = myBreakStory.texts.itemByRange(myBfBreakFrame.insertionPoints[-1],myBreakStory.insertionP oints[-1]);

                                                  myOversetText.select();

                                                  app.cut();

                                                  app.select(myAfBreakFrame.insertionPoints[0]);

                                                  app.paste();

                     

                                        }

                              }

                    }

                     

                     

                    Message was edited by: Jaxiter

                     

                    Message was edited by: Jaxiter
                    Somehow the forum software inserts white-space on its own :s - For the code to work, search for
                    ,myB reakStory.insertionPoints[-1]);
                    and replace with
                    ,myBreakStory.insertionPoints[-1]);

                    • 7. Re: Please provide the Story Splitter script by Adi Ravid?
                      Ian Fraiser Level 1

                      By the way, two notes: I just tested this in CS6 and it works great! However, there were two spaces I had to remove (lines 112 and 132) in "insertionP oints". Cheers!

                      • 8. Re: Please provide the Story Splitter script by Adi Ravid?
                        xmvaldez Level 1

                        Thanks Jaxiter, so much for this. It works great (so far) in CC 2015 with corrections from Ian.

                        • 9. Re: Please provide the Story Splitter script by Adi Ravid?
                          ravisavis Level 1

                          Has Adobe integrated this function into inDesign (a function to split the spreads)? We shouldn't have to use this script. It is 2017, it is completely unconscionable of Adobe corporation (if it hasn't done so already, and I am just not aware) to have not incorporated this function into the application. I have been using this script for years. Does adobe not care about this product, about inDesign and its users? Because, if adobe hasn't incorporated this function into the software it shows quite obviously that adobe doesn't care about this application or its users, and I should think about using another software application. If adobe has incorporated this function, then I take back what I have said.

                          • 11. Re: Please provide the Story Splitter script by Adi Ravid?
                            Sleem Level 1

                            Here is the final script, open notepad, paste the code, save as StorySplitter.jsx

                             

                            /*
                            ---------------------------------------------------------------------- --------------------------------------------
                            StorySplitter
                            ---------------------------------------------------------------------- --------------------------------------------
                            An InDesign CS/CS2/CS3 JavaScript by FourAces
                            © The Final Touch 2006
                            Version 3.0.0
                            
                            
                            Splits the selected Story to separate Text Frames, while maintaining their contents.
                            ---------------------------------------------------------------------- --------------------------------------------
                            */
                            var myScriptVer = "3.0";
                            
                            
                            if(app.documents.length != 0){
                                      var mySelection = app.activeDocument.selection;
                                      if(mySelection.length != 0){
                                                myObjectType = mySelection[0].constructor.name;
                                                if(myObjectType == "TextFrame"){
                                                          //The Interface Dialog
                                                          var myDialog = app.dialogs.add({name:"Story Splitter v"+ myScriptVer});
                                                          with(myDialog){
                                                                    with(dialogColumns.add()){
                                                                              with (dialogRows.add()){
                                                                                        with(borderPanels.add()){
                                                                                                  var mySplitOptions = radiobuttonGroups.add();
                                                                                                  with(mySplitOptions){
                                                                                                            radiobuttonControls.add({staticLabel:"Split All Frames", checkedState:true});
                                                                                                            radiobuttonControls.add({staticLabel:"Split Before Selected Frame"});
                                                                                                            radiobuttonControls.add({staticLabel:"Split After Selected Frame"});
                                                                                                  }
                                                                                        }
                                                                              }
                                                                              with (dialogRows.add()){
                                                                                        staticTexts.add({staticLabel:"© The Final Touch"});
                                                                              }
                                                                    }
                                                          }
                                                          var myResult = myDialog.show({name:"SplitOptions"});
                                                          if(myResult == true){
                                                                    var myStory = mySelection[0].parentStory;
                                                                    if(app.version.split(".")[0] >= 5){
                                                                              var myTextFrames = myStory.textContainers;
                                                                    }
                                                                    else{
                                                                              var myTextFrames = myStory.textFrames;
                                                                    }
                                                                    var myStoryFramesCount = myTextFrames.length;
                                                                    if(myStoryFramesCount > 1){
                                                                              for(f = 0; f < myStoryFramesCount; f++){
                                                                                        if (mySelection[0] == myStory.textFrames[f]){
                                                                                                  var myTextFrame = f;
                                                                                        }
                                                                              }
                                                                              switch(mySplitOptions.selectedButton){
                                                                                        case 0:
                                                                                                  mySplitAll();
                                                                                                  break;
                                                                                        case 1:
                                                                                                  mySplitBefore();
                                                                                                  break;
                                                                                        case 2:
                                                                                                  mySplitAfter();
                                                                                                  break;
                                                                              }
                                                                    }
                                                                    else{
                                                                              alert("Are You Kidding Me?!\nThe Story you selected has only ONE text frame.");
                                                                    }
                                                          }
                                                }
                                                else{
                                                          alert("Wrong Selection\nYou selected the wrong type of object. Please select a Text Frame.");
                                                }
                                      }
                                      else{
                                                alert("No Selection Made.\nPlease select a Story to split.");
                                      }
                            }
                            else{
                                      alert("No Active Document Found.\nPlease open an InDesign document and select a Story to split.");
                            }
                            
                            
                            //-------------------------------------------------------------------- --------
                            function mySplitAll(){
                                      for(i = 0; i < myStoryFramesCount; i++){
                                                myTextFrames[i].duplicate();
                                      }
                                      for(i = 0; i < myStoryFramesCount; i++){
                                                if(app.version.split(".")[0] >= 5){
                                                          myTextFrames[i].remove();
                                                }
                                                else{
                                                          myTextFrames[0].remove();
                                                }
                                      }
                            }
                            
                            
                            function mySplitBefore(){
                                      if(mySelection[0].previousTextFrame == null){
                                                alert("Unable to break thread.\nThe selected Text Frame is the FIRST text frame of the thread.");
                                      }
                                      else{
                                                var myBfBreakFrame = mySelection[0].previousTextFrame;
                                                var myAfBreakFrame = mySelection[0];
                                                var myBreakStory = myBfBreakFrame.parentStory;
                                                mySelection[0].previousTextFrame = null;
                                                if(myBfBreakFrame.overflows == true){
                                                          var myOversetText = myBreakStory.texts.itemByRange(myBfBreakFrame.insertionPoints[-1],myBreakStory.insertionPoints[-1]);
                                                          myOversetText.select();
                                                          app.cut();
                                                          app.select(myAfBreakFrame.insertionPoints[0]);
                                                          app.paste();
                                                }
                                      }
                            }
                            
                            
                            function mySplitAfter(){
                                      if(mySelection[0].nextTextFrame == null){
                                                alert("Unable Break Thread.\nThe selected Text Frame is the LAST text frame of the thread.");
                                      }
                                      else{
                                                var myBfBreakFrame = mySelection[0];
                                                var myAfBreakFrame = mySelection[0].nextTextFrame;
                                                var myBreakStory = myBfBreakFrame.parentStory;
                                                mySelection[0].nextTextFrame = null;
                                                if(myBfBreakFrame.overflows == true){
                                                          var myOversetText = myBreakStory.texts.itemByRange(myBfBreakFrame.insertionPoints[-1],myBreakStory.insertionPoints[-1]);
                                                          myOversetText.select();
                                                          app.cut();
                                                          app.select(myAfBreakFrame.insertionPoints[0]);
                                                          app.paste();
                            
                                                }
                                      }
                            }