Hello all,
I am using a modified version of tomaxxi's script as seen here (yes I know it is an old thread): http://forums.adobe.com/message/3168013
I know he has a new script, but neither of them can do all indesign files in subfolders as well as the parent folder. I am wondering how I can adjust the following script so that it will pull all .indd files in subfolders of the selected folder.
Additionally, if there is another plugin that does the same thing that would work and has this functionality, I am all ears.
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.length == 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");}