Copy link to clipboard
Copied
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
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]=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.enc
Copy link to clipboard
Copied
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/
Copy link to clipboard
Copied
Cheers, that would be great, much appreciated, I'm not a script writer but know how useful they can be!
Thanks, Tim
Copy link to clipboard
Copied
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]=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); 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.fontFamily + "\t" + myDocFonts .fontStyleName + "\t" + myDocFonts .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), 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/
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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]=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); 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.fontFamily + "\t" + myDocFonts .fontStyleName + "\t" + myDocFonts .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), 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/
Copy link to clipboard
Copied
Perfect, thanks very much.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Yes, it's because you have missing fonts... I'll try to change script soon...
--
tomaxxi
http://indisnip.wordpress.com/
Copy link to clipboard
Copied
Thanks very much, do you ever sleep??
Copy link to clipboard
Copied
yeah, sometimes...
--
tomaxxi
Copy link to clipboard
Copied
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]=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); 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.status == FontStatus.INSTALLED){
var myString = String(myDocFonts.fontFamily + "\t");
try{myString += myDocFonts.fontStyleName + "\t";}catch(_){myString += "[ error reading ]\t";}
try{myString += myDocFonts.location + "\r";}catch(_){myString += "[ error reading ]\r";}
}else{
var myString = String(myDocFonts.fontFamily + "\t");
try{myString += myDocFonts.fontStyleName + "\t";}catch(_){myString += "[ error reading ]\t";}
try{myString += myDocFonts.location + "\t";}catch(_){myString += "[ error reading ]\t";}
myString += "[ " + String(myDocFonts.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), 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/
Copy link to clipboard
Copied
Would there be a way to list the font sizes used for each font type instead of font file location?
For example:
Arial Bold 32pt
Arial 18pt
Myriad Pro 10pt
Copy link to clipboard
Copied
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/
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Does anyone have a working link for 'FontReporter 2' ?
I'm after doing a similar report for 1,000's of InDesign CC documents.
Many thanks
Copy link to clipboard
Copied
Following. Haven't been able to find a working link anywhere. This would be really useful.
Copy link to clipboard
Copied
Wow this script is great! Is there a way to modify it to also list the font sizes used for each font?
example: Arial Bold 32pt, Arial Regular 16pt, etc.
Copy link to clipboard
Copied
Been trying to get this script to run, continues to get an error. Any and all help would be greatly appericated.
Copy link to clipboard
Copied
Change the line
app.open(File(myFolderContents), false);
To
app.open(File(myFolderContents[i]), false);
-Manan
Copy link to clipboard
Copied
On further checking the code I see there are other areas as well which seems to have corrupted due to forum migration. The following code should work
Array.prototype.unique = function () { var i, a = {}, r = [], n = this.length; for (i = 0; i < n; ++i) a[this] = 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); 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");
}
-Manan