7 Replies Latest reply on Aug 23, 2015 10:32 AM by sreekarthik.k@gmail.com

    Number list

    Level 1

      I need to strip off the manual numbers and replace them with automatic paragraph numbers.

       

      1. 1.     text

      2. 2.     text2

       

      Is this possible via scripting. It can be only applied in the number list

        • 1. Re: Number list
          JohnDevlon Level 1

          This could be done using a script. Create a paragraph style using automatic numbering. Then use a GREP search/replace in your script !

          I found this example:

           

          // Clear any previous settings
          app.findGrepPreferences=null;
          app.changeGrepPreferences=null;

          // Set find Grep pattern - To be adjusted
          app.findGrepPreferences.findWhat=”?(.+)$”;

          // Set change Grep pattern - To be adjusted
          app.changeGrepPreferences.changeTo=”$1″;


          // Set the new paragraph style
          app.changeGrepPreferences.appliedParagraphStyle=”APPLE”;

           

          // Do the changes

          app.activeDocument.changeGrep();

           

          The grep pattern needs to be changed to your code !!

           

          You can test your grep pattern in Indesign before you use it in your script

          • 2. Re: Number list
            Level 1

            Thanks John

             

            I have tried like this but its not working via scripting

             

            // Clear any previous settings

            app.findGrepPreferences=null;

            app.changeGrepPreferences=null;

            // Set find Grep pattern - To be adjusted

            app.findGrepPreferences.findWhat="^\d+?\.\t+";

             

             

            // Set change Grep pattern - To be adjusted

            app.changeGrepPreferences.changeTo="";

             

             

            // Set the new paragraph style

            app.changeGrepPreferences.appliedParagraphStyle="NL";

             

             

            // Do the changes

             

             

            app.activeDocument.changeGrep();

            • 3. Re: Number list
              Peter Kahrel Adobe Community Professional & MVP

              You need to escape backslashes: "^\\d+?\\.\\t+";

               

              But the way you did it, without setting a replacement string, only applies the paragraph style NL, it doesn't remove the manual paragraph number. To apply the style and remove the number, do this:

               

              app.findGrepPreferences=null;
              app.changeGrepPreferences=null;
              app.findGrepPreferences.findWhat="^\\d+?\\.\\t+(.)";
              app.changeGrepPreferences.changeTo="$1";
              app.changeGrepPreferences.appliedParagraphStyle="NL";
              app.activeDocument.changeGrep();
              

               

              Peter

              • 4. Re: Number list
                Level 1

                Thanks for this its working file. I need to find the paragraph style with list type number (or) bullet property.

                • 5. Re: Number list
                  Peter Kahrel Adobe Community Professional & MVP

                  What do you mean by 'the paragraph style with list type number (or) bullet property'? A particular paragraph style or any paragraph style with a list type other than None?

                  • 6. Re: Number list
                    Level 1

                    I need to need to strip off the manual numbers only in the list type property paragraph styles.

                     

                    Is this possible to find any paragraph style with list type property.

                    • 7. Re: Number list
                      Peter Kahrel Adobe Community Professional & MVP

                      After line 4 in the above code sample, insert this line:

                       

                      app.findGrepPreferences.bulletsAndNumberingListType = ListType.NUMBERED_LIST;

                      • 8. Re: Number list
                        Level 1

                        Ya. Its working fine.