6 Replies Latest reply on Jun 3, 2012 2:04 AM by ted42

    Need a scripting guide

    John J David Level 1

      We have a couple of InDesign CS4 files with us. We need to genereate a report as follows:

       

      1. Need to take used paragraph and character styles as chapterwise. Do not take entire style available in the document.

      2. Also required the corresponding font name and font style that appear next to the style.

       

      for e.g. the report (.csv format) shows as illustrated below.

       

      Used style information
      File nameParagraph stylesFont FamilyFont StyleCharacter stylesFont FamilyFont Style
      Chapter 1.inddparaTimesRomaninsideTimesBold
      para1TimesRomaninside1TimesItalic
      para2TimesRomaninside2TimesBold
      para3TimesRomaninside3TimesBold Italic
      para4Times TenRomaninside4Times TenBold
      para5Times TenRomaninside5Times TenBold Italic
      para6Times TenRomaninside6Times TenItalic
      para7HelveticaRegularinside7HelveticaBold
      para8HelveticaRegularinside8HelveticaBold Italic
      Chapter 2.inddparaTimesRomaninsideTimesBold
      para1TimesRomaninside1TimesItalic
      para2TimesRomaninside2TimesBold
      para3TimesRomaninside3TimesBold Italic
      para4Times TenRomaninside4Times TenBold
      para5Times TenRomaninside5Times TenBold Italic
      para6Times TenRomaninside6Times TenItalic
      para7HelveticaRegularinside7HelveticaBold
      para8HelveticaRegularinside8HelveticaBold Italic

       

      Any help much appreciated. . .

       

      JA

        • 1. Re: Need a scripting guide
          Velprakash

          Hi John,

                 Use the following scripting.I hope it'll be useful 4 u.I don't have enough time to compress the whole what u want...

           

          doc=app.activeDocument;

          //Paragraph Styles.......................................

          var styles = doc.stories.everyItem().paragraphs.everyItem().appliedParagraphStyle;

          var len=styles.length;

          a=[];

          for(var i=0;i<len;i++)

          {

              a.push(styles[i].name);

              }

          alert(a);

           

           

          //Character Styles.........................................

           

          var chrstyles=doc.stories.everyItem().paragraphs.everyItem().appliedCharacterStyle;

          var len1=chrstyles.length;

          b=[];

          for(var i=0;i<len1;i++)

          {

              b.push(chrstyles[i].name);

              }

          alert(b);

           

          Regards,

          Vel.

          • 2. Re: Need a scripting guide
            John J David Level 1

            Thanks a lot Vel. But the program does not work well. It shows two alerts 1. paragraph styles 2. character styles. After that it does not written any csv file. Also I need to run on the batch mode. . .

            • 3. Re: Need a scripting guide
              Velprakash Level 1

              Hi John,

                    I worked out this as in .txt. It works fine. You use this codes and try with .csv.

              Try this. Before that u've to create a empty text file in the desktop and copy the path to be saved...

               

              var doc1 = app.documents[0];

              var doc2 = app.documents[1];

              //Paragraph Styles.......................................

              var styles = doc1.stories.everyItem().paragraphs.everyItem().appliedParagraphStyle;

              var len=styles.length;

              a=[];

              for(var i=0;i<len;i++)

              {

                  a.push(styles[i].name);

                  }

              //alert(a);

               

               

              //Character Styles.........................................

               

              var chrstyles=doc1.stories.everyItem().paragraphs.everyItem().appliedCharacterStyle;

              var len1=chrstyles.length;

              b=[];

              for(var i=0;i<len1;i++)

              {

                  b.push(chrstyles[i].name);

                  }

               

               

              var styles1 = doc2.stories.everyItem().paragraphs.everyItem().appliedParagraphStyle;

              var len1=styles1.length;

              c=[];

              for(var i=0;i<len1;i++)

              {

                  c.push(styles1[i].name);

                  }

              //alert(a);

               

               

              //Character Styles.........................................

               

              var chrstyles1=doc2.stories.everyItem().paragraphs.everyItem().appliedCharacterStyle;

              var len2=chrstyles1.length;

              d=[];

              for(var i=0;i<len2;i++)

              {

                  d.push(chrstyles1[i].name);

                  }

               

               

              //alert(b);

              var filenew=File("C:/Documents and Settings/velprakashk/Desktop/vel.txt");       //The created empty text file path here...

              var f = filenew.open("w");

              var txt=filenew.read();

              txt=doc1.name +"\r";

              txt=txt+"ParagraphStyles:\r"

              txt=txt +a + "\r";

              txt=txt+"CharacterStyles:\r"

              txt=txt + b + "\r";

              txt=txt +doc2.name +"\r";

              txt=txt+"ParagraphStyles:\r"

              txt=txt +c + "\r";

              txt=txt+"CharacterStyles:\r"

              txt=txt + d + "\r";

              alert(txt);

              filenew.write(txt);

              filenew.close();

               

              Now the things is saved in the file in desktop...

               

              With Regards,

              Vel.

              • 4. Re: Need a scripting guide
                John J David Level 1

                Hi Vel,

                 

                Still got a Javascript error while running the script. Kindly help me out to come across.

                 

                JA

                • 5. Re: Need a scripting guide
                  Velprakash Level 1

                  what's the error showing? and where? Can u please notify me...

                  • 6. Re: Need a scripting guide
                    ted42

                    Why are you asking others to do your work? he gave you the hints how to get your data, if you look a little bit for scripting help you can find an api documentation for example here:

                    http://www.jongware.com/idjshelp.html

                    And there are plenty of javascript tutorials on he web...

                    If you want a complete solution I suggest hiring a developer.

                     

                    It is not a long way from haing the data to putting it into a file:

                    http://lmgtfy.com/?q=indesign+write+file+script

                     

                    considering you have 137 posts one might think you did a little scripting yourself, I mean it is nice to get fully working solution, but I hink on help sites you get help were you need it and do a bunch of the work your self.