Reply To: Script to print Found strings on an InDesign page

Home Page / Forums / General InDesign Topics (CLOSED) / Script to print Found strings on an InDesign page / Reply To: Script to print Found strings on an InDesign page

#92925

Hi Tim,

here is your example. Realize that this is not the order by page!

var list = [
  "(Genesis|Gen.?)",
  "(Psalms|Ps.?)",
  "(Jeremiah|Jer.?)",
  "(Moses)"
];

var curDoc = app.activeDocument,
nList = list.length,
curListItem,
strToSearch,
found,
foundList = [],
curFound;

app.findGrepPreferences = app.changeGrepPreferences = null;
app.findChangeGrepOptions.includeFootnotes = true;

for (var i = 0; i < nList; i++) {
  curListItem = list[i];  
  strToSearch = "(" + curListItem + " d{1,3}[:–]d{1,3}([;–]d{1,3})?(, d{1,3})?(; d{1,3})?([:?]d{1,3})?)";
  app.findGrepPreferences.findWhat = strToSearch;
  found = curDoc.findGrep();
  if (found.length > 0) {
    for (var j = 0; j < found.length; j++) {
      curFound = found[j];      
      foundList.push(curFound.contents);
    }
  }
}

app.findGrepPreferences = app.changeGrepPreferences = null;

alert(foundList);

var tf = curDoc.textFrames.add({geometricBounds: [10, 10, 200, 200]});
tf.contents = foundList.join("\r");

Kai

This article was last modified on March 17, 2017

Comments (0)

Loading comments...