2 Replies Latest reply on May 10, 2014 12:28 AM by hasvi

    Need log report by script

    hasvi Level 1

      Hi,

       

      I need to match Template file 'paragraph style’ names with ‘Standardized InDesign style names.xls’ (we defined already our standard style names in excel sheet), if any style name variation between Template and excel sheet, generate the log report for the mismatched ‘paragraph style name’.

       

      For instance My Template file paragraph style names: TT, CT, H1, H2, H3    

                         My excel sheet paragraph style names: TTL, CT, H1, H2, H4

       

      Here mismatched style names is excel sheet: TTL, H4 this detail has to generate in log report.

       

      Pls help by script.

       

      Thanks

      hasvi

        • 1. Re: Need log report by script
          BEGINNER_X Level 3

          Hi Hasvi,

           

          Thanks to csm_phil, because code written by him.

           

          First, you have to convert the excel file into "*.csv or tab delimited" files format. (I use comma delimited file .csv).

           

          Use the below code:

           

          var myFile = File.openDialog("Choose a tab delimitted txt file:");  
          if (!myFile){  
          exit();  
          }       
            
          var myArray = []   
          myFile.open('r');  
          while (myFile.eof==false){  
              var line=myFile.readln().split(",");  
              myArray.push(line[0]);  
              }  
            
          var myDoc = app.activeDocument;  
          var myPstyles = app.activeDocument.allParagraphStyles;  
            
          Array.prototype.contains = function(obj) {  
              var i = this.length;  
              while (i--) {  
                  if (this[i] === obj) {  
                      return true;  
                  }  
              }  
              return false;  
          }  
            
          var myMissingStyle =[];  
          for(i=2; i<myPstyles.length; i++){  
              var myS =myPstyles[i].name;  
              if(myArray.contains(myS) !=true){  
                  myMissingStyle.push(myS);  
                  }  
              }  
            
          //I showed only missing styles names, If you want a report file, please you have generate it.  
          alert(myMissingStyle.join("\n"));  
          
          

          For create report:

           

          var myTextFile = new File("~/Desktop/abc.txt")

          myTextFile.open(w)

          myTextFile.write(myMissingStyle)

          myTextFile.close();

          alert("Process Completed")

           

          Thanks

          Siraj

          • 2. Re: Need log report by script
            hasvi Level 1

            Hi,

             

             

            Many thanks to 'csm_phil' and you,

             

             

            Need little more on this script, I need character style and paragraph style mismatch report.

             

             

            Thanks

            Hasvi