Skip to main content
Known Participant
December 22, 2017
Answered

Update page number placeholders in index locators

  • December 22, 2017
  • 1 reply
  • 796 views

The index that I'm working on has temporary placeholders for the page numbers of the endnotes, e.g., 000 note 1. I've put together a table that maps the page numbers to the note numbers. I am not script savvy, but it would be great to have a script that would swap in the page numbers. The locators have a unique character style, so perhaps the script could search for the character style, and when it finds an instance of it, draw the page number(s) from the table.

Here are some sample entries:

Absolutism, 000 note 3

“Accommodation,” meaning of term, 000 note 12

Action, 000 note 6

Active and passive characteristics, 000 note 10

Acton, Alfred, 000 note 10

Acts, Book of, 000 note 7

Adaequatio rei et intellectus, 000 note 9

Adjectives, substantive, as translation issue, 000 note 8

Affectio, meaning of, 000 note 15

Ages

“the Age of Freedom,” 000 note 12

ages of humanity, 000 note 6

Golden Age, 000 note 18

a new age, 000 note 20

Agrippa, Henry Cornelius, 000 note 19

Alexander the Great, 000 note 4

Amalekites, 000 note 2

Amos, Book of, in history of apocalyptic, 000 note 7

Anamorphoscope, 000 note 16

And here's a chunk of the page numbers table:

Page #Note #

527

1

527

2

527

3

528

4

528

5

528

6

528–529

7

529

8

529-530

9

530

10

530

11

530

12

530

13

530

14

531

15

531-532

16

532

17

532

18

532

19

532

20

Any help with expediting this fiddly task would be much appreciated!

Alicia

This topic has been closed for replies.
Correct answer Peter Kahrel

Yes, locators in notes are a pain in InDesign. To deal with your approach, place your page numbers table in a separate text frame and name the frame page numbers table on the Layers panel. Then run this script:

table = app.documents[0].textFrames.item ('page numbers table').tables[0];

rows = table.rows.everyItem().getElements();

hash = {};

for (i = rows.length-1; i >= 0; i--) {

  hash[rows.cells[1].contents] = rows.cells[0].contents;

}

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = '000 note \\d+';

dummies = app.documents[0].findGrep();

for (i = dummies.length-1; i >= 0; i--) {

  parts = dummies.contents.split (' note ');

  dummies.characters.itemByRange(0,2).contents = hash[parts[1]];

}

The script doesn't check any errors, so make sure you name the frame correctly.

Peter

1 reply

Peter KahrelCommunity ExpertCorrect answer
Community Expert
December 23, 2017

Yes, locators in notes are a pain in InDesign. To deal with your approach, place your page numbers table in a separate text frame and name the frame page numbers table on the Layers panel. Then run this script:

table = app.documents[0].textFrames.item ('page numbers table').tables[0];

rows = table.rows.everyItem().getElements();

hash = {};

for (i = rows.length-1; i >= 0; i--) {

  hash[rows.cells[1].contents] = rows.cells[0].contents;

}

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = '000 note \\d+';

dummies = app.documents[0].findGrep();

for (i = dummies.length-1; i >= 0; i--) {

  parts = dummies.contents.split (' note ');

  dummies.characters.itemByRange(0,2).contents = hash[parts[1]];

}

The script doesn't check any errors, so make sure you name the frame correctly.

Peter

Known Participant
December 27, 2017

The script works perfectly, Peter. I am very grateful! What a time-saver this will be for us. Thank you for sharing your time and expertise so generously.

Alicia