Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Export All Stories from Book to InCopy

Tagged: 

Return to Member Forum

  • Author
    Posts
    • #64633

      Hello,

      I’m wondering if anyone has run across a script that will export all the Stories in each document contained in a Book (.indb) to InCopy. I tried creating something myself (it was very very basic, I really don’t know much about scripting), but I had to hit the “Save” button for every document and it choked if there were no Stories available to export.

      var d = app.activeBook.bookContents.everyItem().fullName;
      for (i=0;i<d.length;i++){
      app.open(d[i]);
      with (app.activeDocument){
      app.menuActions.itemByID(94979).invoke();
      save();
      close();
      }
      }

      Ideally, I’d click to run the script, select which book, a folder to save in for all documents, and then the script would go through all the documents and export any Stories. Thoughts? Ideas? Appreciate any help. Thanks.

    • #78010

      Did you ever find a solution for this? I’m looking to do the same thing.

    • #78015
      Peter Kahrel
      Participant

      Here’s a script that exports all stories on document pages (i.e. skipping stories on master spreads). It saves the icml files in the documents folders using the document name followed by a number (the numbers look random but are the storyies’ IDs). (Adding functionality to select a book and an output folder is a hassle.)

      Peter

      [CODE]
      (function(){

      function exportDocumentStories (doc) {
      var stories = doc.stories.everyItem().getElements();
      var baseName = String(doc.fullName).replace(/\.indd$/,’ ‘);
      for (var i = stories.length-1; i >= 0; i–) {
      if (stories[i].textContainers[0].parent instanceof Spread) {
      f = File (baseName + stories[i].id + ‘.icml’);
      stories[i].exportFile (ExportFormat.INCOPY_MARKUP, f);
      }
      }
      }

      function exportICML() {
      var chapters = app.activeBook.bookContents.everyItem().getElements();
      for (var i = 0; i < chapters.length; i++){
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
      app.open (chapters[i].fullName);
      exportDocumentStories (app.documents[0]);
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
      }
      }

      if (app.books.length === 1) {
      exportICML();
      } else {
      alert (‘Open (just) one book.’);
      }

      }());
      [CODE]

    • #78016
      Peter Kahrel
      Participant

      (Sorry, got the coding tags wrong.)


      (function(){

      function exportDocumentStories (doc) {
      var stories = doc.stories.everyItem().getElements();
      var baseName = String(doc.fullName).replace(/\.indd$/,’ ‘);
      for (var i = stories.length-1; i >= 0; i–) {
      if (stories[i].textContainers[0].parent instanceof Spread) {
      f = File (baseName + stories[i].id + ‘.icml’);
      stories[i].exportFile (ExportFormat.INCOPY_MARKUP, f);
      }
      }
      }

      function exportICML() {
      var chapters = app.activeBook.bookContents.everyItem().getElements();
      for (var i = 0; i < chapters.length; i++){
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
      app.open (chapters[i].fullName);
      exportDocumentStories (app.documents[0]);
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
      }
      }

      if (app.books.length === 1) {
      exportICML();
      } else {
      alert (‘Open (just) one book.’);
      }

      }());

    • #78017
      Peter Kahrel
      Participant

      Still doesn’t look right. But you can copy the script text anyway.

      P.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.
Forum Ads