Highlighted

Report on fonts from batch of documents

Community Beginner ,
Sep 27, 2010

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.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/

Topics

Scripting

Views

2.8K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Report on fonts from batch of documents

Community Beginner ,
Sep 27, 2010

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.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/

Topics

Scripting

Views

2.8K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Advisor ,
Sep 27, 2010

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/

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Sep 27, 2010

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Advisor ,
Sep 27, 2010

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/

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Sep 27, 2010

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Advisor ,
Sep 27, 2010

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/

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Sep 28, 2010

Copy link to clipboard

Copied

Perfect, thanks very much.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Sep 28, 2010

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?Screen shot 2010-09-28 at 11.19.24.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Advisor ,
Sep 28, 2010

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/

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Sep 28, 2010

Copy link to clipboard

Copied

Thanks very much, do you ever sleep??

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Advisor ,
Sep 28, 2010

Copy link to clipboard

Copied

yeah, sometimes...

--

tomaxxi

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Advisor ,
Sep 28, 2010

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/

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Advisor ,
Sep 29, 2010

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/

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Sep 30, 2010

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jul 25, 2019

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Neosans LATEST
New Here ,
Sep 14, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...