13 Replies Latest reply on Sep 30, 2010 2:53 AM by talltim1

    Report on fonts from batch of documents

    talltim1 Level 1

      Hi, does anyone know if there is a script that can go through a folder of a thousand indesign files and create a report (with two choices) of what fonts are used. Choice 1: Just a list of fonts have been used without repeating what fonts have been used... so if "Times Roman" has been used on 30 indesign files the report only mentions "Times Roman once. Choice 2: A list of file names and what fonts are used in each file.

       

      Cheers, Tim

        • 1. Re: Report on fonts from batch of documents
          Marijan Tompa [tomaxxi] Level 4

          Hey!

           

          Well, it can be done really easily. You have to loop through all documents in folder, and for each to read app.activeDocument.fonts. I'll try to write something for you if you need help.

           

          --

          tomaxxi

          http://indisnip.wordpress.com/

          1 person found this helpful
          • 2. Re: Report on fonts from batch of documents
            talltim1 Level 1

            Cheers, that would be great, much appreciated, I'm not a script writer but know how useful they can be!

             

            Thanks, Tim

            • 3. Re: Report on fonts from batch of documents
              Marijan Tompa [tomaxxi] Level 4

              Hey Tim!

               

              This works with hidden documents to gain more speed, so you have to close all documents before executing.

               

              Here you go:

               

              Array.prototype.unique = function (){var i, a = {},r = [],n = this.length;for( i=0 ; i<n ; ++i ) a[this[i]]=1;for( i in a ) r.push(i);return r;}

              if(app.documents.length == 0){
                  fontReporter();
              }else{
                  alert("Please close all documents!","Font Report Creator");
              }

              function fontReporter(){
              // write report to file
              var writeReport = function(myData, myFile){myFile.open ('w'); myFile.encoding = 'UTF-8'; for(var d = 0; d < myData.length; d++)myFile.write (myData[d]); myFile.close (); }
              // collect info from document
              var createFontReport = function(){
                  var myDoc = app.documents[0];
                  var myDocFonts = myDoc.fonts;
                  var myDocName = myDoc.name;
                  var myReportFile = File(app.documents[0].fullName.path + "/" + myDocName + " - Font Report.txt");
                  var myFonts = [];
                  myFonts.push("//// Font report for file: [ " + myDocName + " ] ////\r\r");
                  for(var f = 0; f < myDocFonts.length; f++){var myString = myDocFonts[f].fontFamily + "\t" + myDocFonts[f].fontStyleName + "\t" + myDocFonts[f].location + "\r"; myFonts.push(myString); myFontsAll.push(myString);}
                  myFonts.sort();
                  myFonts.push("\rFonts used count: " + f + " ////");
                  writeReport(myFonts, myReportFile);
              }

                  var myFontsAll = [];

                  // open/report/close
                  var myFolder = Folder.selectDialog("Please select a folder containing the InDesign files.");
                  if(myFolder == null){alert("No folder selected!","Font Report Creator"); exit();}

                  var myFolderContents = myFolder.getFiles("*.indd");
                  if(myFolderContents.lenght == 0){alert("No InDesign files in folder!","Font Report Creator"); exit();}

                  for (var i = 0; i < myFolderContents.length; i++) {
                      app.open(File(myFolderContents[i]), false);
                      if(app.documents[0].saved == true)createFontReport();
                      app.documents[0].close(SaveOptions.no);
                  }

                  // complete report
                  myFontsAll = myFontsAll.unique();
                  myFontsAll.sort();
                  myFontsAll.unshift("//// Font report for folder: [ " + myFolder + " ]////\r\r");
                  myFontsAll.push("\r//// Fonts used count: " + (myFontsAll.length - 1) + " ////");
                  var myReportFile = File(myFolder + "/All [INDD] Documents Font Report.txt");
                  writeReport(myFontsAll, myReportFile);

              alert("Font reports created!","Font Report Creator");
              }

               

              Hope it helps!

               

              --

              tomaxxi

              http://indisnip.wordpress.com/

              1 person found this helpful
              • 4. Re: Report on fonts from batch of documents
                talltim1 Level 1

                Hey thanks for that. But would it be asking too much if there could be two adjustments:-)?

                 

                1. If the script could ignore any error messages such as missing links etc when going through the documents.

                 

                2. If the reports for the individual files could be collated into one document.

                 

                Many thanks, Tim

                • 5. Re: Report on fonts from batch of documents
                  Marijan Tompa [tomaxxi] Level 4

                  Ok, no big changes

                   

                  Here is your script:

                   

                  Array.prototype.unique = function (){var i, a = {},r = [],n = this.length;for( i=0 ; i<n ; ++i ) a[this[i]]=1;for( i in a ) r.push(i);return r;}

                  if(app.documents.length == 0){
                      fontReporter();
                  }else{
                      alert("Please close all documents!","Font Report Creator");
                  }

                  function fontReporter(){
                  app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
                  // write report to file
                  var writeReport = function(myData, myFile){myFile.open ('w'); myFile.encoding = 'UTF-8'; for(var d = 0; d < myData.length; d++)myFile.write (myData[d]); myFile.close (); }
                  // collect info from document
                  var createFontReport = function(){
                      var myDoc = app.documents[0];
                      var myDocFonts = myDoc.fonts;
                      var myDocName = myDoc.name;
                      myFonts.push("//// Font report for file: [ " + myDocName + " ] ////\r\r");
                      for(var f = 0; f < myDocFonts.length; f++){var myString = myDocFonts[f].fontFamily + "\t" + myDocFonts[f].fontStyleName + "\t" + myDocFonts[f].location + "\r"; myFonts.push(myString); myFontsAll.push(myString);}
                      //myFonts.sort();
                      myFonts.push("\r//// Fonts used count: " + f + " ////\r\r\r");

                  }

                      var myFonts = [];
                      var myFontsAll = [];

                      // open/report/close
                      var myFolder = Folder.selectDialog("Please select a folder containing the InDesign files.");
                      if(myFolder == null){alert("No folder selected!","Font Report Creator"); exit();}

                      var myFolderContents = myFolder.getFiles("*.indd");
                      if(myFolderContents.lenght == 0){alert("No InDesign files in folder!","Font Report Creator"); exit();}

                      for (var i = 0; i < myFolderContents.length; i++) {
                          app.open(File(myFolderContents[i]), false);
                          if(app.documents[0].saved == true)createFontReport();
                          app.documents[0].close(SaveOptions.no);
                      }

                      var myReportFile = File(myFolder + "/" + "Separate document report - Font Report.txt");
                      writeReport(myFonts, myReportFile);

                      // complete report
                      myFontsAll = myFontsAll.unique();
                      myFontsAll.sort();
                      myFontsAll.unshift("//// Font report for folder: [ " + myFolder + " ]////\r\r");
                      myFontsAll.push("\r//// Fonts used count: " + (myFontsAll.length - 1) + " ////");
                      myReportFile = File(myFolder + "/All [INDD] Documents Font Report.txt");
                      writeReport(myFontsAll, myReportFile);

                  app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;

                  alert("Font reports created!","Font Report Creator");
                  }

                   

                  --

                  tomaxxi

                  http://indisnip.wordpress.com/

                  • 6. Re: Report on fonts from batch of documents
                    talltim1 Level 1

                    Perfect, thanks very much.

                    • 7. Re: Report on fonts from batch of documents
                      talltim1 Level 1

                      Hi, how are things? I'm running into a little trouble with that script. I've attached and error message here. I think it may be something to with missing fonts?Screen shot 2010-09-28 at 11.19.24.png

                      • 8. Re: Report on fonts from batch of documents
                        Marijan Tompa [tomaxxi] Level 4

                        Yes, it's because you have missing fonts... I'll try to change script soon...

                         

                        --

                        tomaxxi

                        http://indisnip.wordpress.com/

                        • 9. Re: Report on fonts from batch of documents
                          talltim1 Level 1

                          Thanks very much, do you ever sleep??

                          • 10. Re: Report on fonts from batch of documents
                            Marijan Tompa [tomaxxi] Level 4

                            yeah, sometimes...

                             

                            --

                            tomaxxi

                            • 11. Re: Report on fonts from batch of documents
                              Marijan Tompa [tomaxxi] Level 4

                              Error you were getting wasn't caused by missing font, it's maybe damaged font or something else.

                               

                              Array.prototype.unique = function (){var i, a = {},r = [],n = this.length;for( i=0 ; i<n ; ++i ) a[this[i]]=1;for( i in a ) r.push(i);return r;}

                              if(app.documents.length == 0){
                                  fontReporter();
                              }else{
                                  alert("Please close all documents!","Font Report Creator");
                              }

                              function fontReporter(){
                              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
                              // write report to file
                              var writeReport = function(myData, myFile){myFile.open ('w'); myFile.encoding = 'UTF-8'; for(var d = 0; d < myData.length; d++)myFile.write (myData[d]); myFile.close (); }
                              // collect info from document
                              var createFontReport = function(){
                                  var myDoc = app.documents[0];
                                  var myDocFonts = myDoc.fonts;
                                  var myDocName = myDoc.name;
                                  myFonts.push("//// Font report for file: [ " + myDocName + " ] ////\r\r");
                                  for(var f = 0; f < myDocFonts.length; f++){
                                      if(myDocFonts[f].status == FontStatus.INSTALLED){
                                          var myString = String(myDocFonts[f].fontFamily + "\t");
                                          try{myString += myDocFonts[f].fontStyleName + "\t";}catch(_){myString += "[ error reading ]\t";}
                                          try{myString += myDocFonts[f].location + "\r";}catch(_){myString += "[ error reading ]\r";}
                                      }else{
                                          var myString = String(myDocFonts[f].fontFamily + "\t");
                                          try{myString += myDocFonts[f].fontStyleName + "\t";}catch(_){myString += "[ error reading ]\t";}
                                          try{myString += myDocFonts[f].location + "\t";}catch(_){myString += "[ error reading ]\t";}
                                          myString += "[ " + String(myDocFonts[f].status) + " ]\r";
                                      }
                                      myFonts.push(myString);
                                      myFontsAll.push(myString);
                                  }
                                  //myFonts.sort();
                                  myFonts.push("\r//// Fonts used count: " + f + " ////\r\r\r");

                              }

                                  var myFonts = [];
                                  var myFontsAll = [];

                                  // open/report/close
                                  var myFolder = Folder.selectDialog("Please select a folder containing the InDesign files.");
                                  if(myFolder == null){alert("No folder selected!","Font Report Creator"); exit();}

                                  var myFolderContents = myFolder.getFiles("*.indd");
                                  if(myFolderContents.lenght == 0){alert("No InDesign files in folder!","Font Report Creator"); exit();}

                                  for (var i = 0; i < myFolderContents.length; i++) {
                                      app.open(File(myFolderContents[i]), false);
                                      if(app.documents[0].saved == true)createFontReport();
                                      app.documents[0].close(SaveOptions.no);
                                  }

                                  var myReportFile = File(myFolder + "/" + "Separate document report - Font Report.txt");
                                  writeReport(myFonts, myReportFile);

                                  // complete report
                                  myFontsAll = myFontsAll.unique();
                                  myFontsAll.sort();
                                  myFontsAll.unshift("//// Font report for folder: [ " + myFolder.fsName + " ]////\r\r");
                                  myFontsAll.push("\r//// Fonts used count: " + (myFontsAll.length - 1) + " ////");
                                  myReportFile = File(myFolder + "/All [INDD] Documents Font Report.txt");
                                  writeReport(myFontsAll, myReportFile);

                              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;

                              alert("Font reports created!","Font Report Creator");
                              }

                               

                              Hope it will work fine for you now.

                               

                              --

                              tomaxxi

                              http://indisnip.wordpress.com/

                              • 12. Re: Report on fonts from batch of documents
                                Marijan Tompa [tomaxxi] Level 4

                                Hey!

                                 

                                I've created even better script than this one.

                                If you are interested take a look here: http://bit.ly/ckbiRR

                                 

                                --

                                tomaxxi

                                http://indisnip.wordpress.com/

                                • 13. Re: Report on fonts from batch of documents
                                  talltim1 Level 1

                                  That's great, good work.

                                   

                                  One other suggestion as an option is in the report where it collates the fonts used, that the file names for each document that font has been used in follows the font information... so:

                                  Times (doc1.indd, doc7.indd, doc124.indd)

                                  Helvetica (doc2.indd, doc7.indd, doc394.indd)

                                   

                                  etc

                                   

                                  Regards, Tim