2 Replies Latest reply on Apr 10, 2014 2:03 AM by Kasyan Servetsky

    How to automate a redundant task on PC to "Include Prefix when Numbering Pages"

    la_miller

      I work in book publishing and we're generating indices using the book feature. The big problem is that for the print version we need the folios styled a certain way "without a prefix" but to create our index in the book feature, the prefix needs to be turned on.

       

       

      Is there any way to do any kind of drag and drop so I don't have to open every chapter of the file to turn the prefix on? Though it doesn't take long, it's repetitive and has to be done every time we update our books. (The "Section Prefix" information is alreay inserted, it's just a matter of toggling it on or off depending on what doing in the InD file.)

       

       

      I do not write scripts. It seems like a simple task but would take me months to figure out. If you can send me to someone who can figure out how to automate this task, I would greatly appreciate your help.

       

      Macgrunt was able to help me but then I realized I was on a PC. Is this something that can be done in Javascript?

        • 1. Re: How to automate a redundant task on PC to "Include Prefix when Numbering Pages"
          Kasyan Servetsky Level 5

          This script turns on "Include Prefix when Numbering Pages" in all sections in the current document.

           

          Main();
          
          function Main() {
              if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true);
              var doc = app.activeDocument;
              if (!app.activeDocument.saved) ErrorExit("The current document has not been saved since it was created. Please save the document and try again.", true);
              
              var sections = doc.sections;
              for (var i = 0; i < sections.length; i++) {
                  sections[i].includeSectionPrefix = true;
              }
          }
          
          function ErrorExit(error, icon) {
              alert(error, scriptName, icon);
              exit();
          }
          

           

          To turn them off, save it with a different name and change "true" to "false":

           

          sections[i].includeSectionPrefix = false;
          
          • 2. Re: How to automate a redundant task on PC to "Include Prefix when Numbering Pages"
            Kasyan Servetsky Level 5

            Here's a version that batch-processes the selected folder with InDesign documents as you asked in PM.

             

            Main();
            
            function Main() {
                var inddFile, doc,
                inddFolder = Folder.selectDialog("Choose a folder with InDesign documents.");
                if (inddFolder == null) exit();
                
                var inddFiles = inddFolder.getFiles("*.indd");
                if (inddFiles.length == 0) ErrorExit("Found no InDesign documents in the selected folder.", true);
            
                for (var i = 0; i < inddFiles.length; i++) {
                    inddFile = inddFiles[i];
                    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
                    doc = app.open(inddFile);
                    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;    
                    
                    sections = doc.sections;
                    
                    for (var j = 0; j < sections.length; j++) {
                        sections[j].includeSectionPrefix = true;
                    }
                
                    doc.close(SaveOptions.YES);
                }
            }
            
            function ErrorExit(error, icon) {
                alert(error, scriptName, icon);
                exit();
            }
            

             

            You can also use this script to run a script or a set of scripts on a bunch of files. (Warning! It's not totally tested)