Reply To: Replace fonts in all documents in a book

Home Page / Forums / General InDesign Topics (CLOSED) / Replace fonts in all documents in a book / Reply To: Replace fonts in all documents in a book

#86006

Maybe too late, but I wrote the attached lines a year ago and they might be helpful:

if (app.books.length != 1) {
  alert("Please open one book!");
  exit();
}
 
var userInterAct = app.scriptPreferences.userInteractionLevel;
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
 
var curBook = app.books[0];
var allDocuments = curBook.bookContents;
app.findTextPreferences = app.changeTextPreferences = null;
 
for (var n = 0; n < allDocuments.length; n++) {
  var curPath = allDocuments[n].fullName;
  var curDoc = app.open(File(curPath));
    
  changeFont("Minion ProItalic", "Myriad ProItalic"); // enter here your fontnames
  curDoc.save();
  curDoc.close();
}
 
function changeFont(currFont, ChangeFont) {
  app.findTextPreferences.appliedFont = currFont;
  app.changeTextPreferences.appliedFont = ChangeFont;
  app.activeDocument.changeText();
}
	
app.findTextPreferences = app.changeTextPreferences = null;
app.scriptPreferences.userInteractionLevel = userInterAct;

The two fonts must be entered in the line ‘changeFont(); The tab () devides the font family from the font style and must be set.

Kai

This article was last modified on June 23, 2016

Comments (0)

Loading comments...