Skip to main content
SuzzyFlamingo
Inspiring
February 7, 2026
Answered

Need help with script or other solution

  • February 7, 2026
  • 3 replies
  • 118 views

Hi, Dear Friends!

I see ID puts all endnotes from all stories in the same text frame at the end of the doc. I am Ok with that but I would like each EN to show “where it is coming from”

So if the EN was inserted in text fram “foo1” it should insert and endnote witht refernce number folowed by the text “foo1” and look like this:

  1. [foo1] here i write the endnote.
  2. [foo5] here i write another end note

I asked ChatGPT and Grok for help and the totally failed.

All help is appreciated!

Thank you, and have a good day!
Susan Flamingo

    Correct answer Peter Kahrel

    @SuzzyFlamingo -- That turns out not to be very straightforward. Better to run the script once you’ve added all your notes. Of course, you might need to add one or more notes after you’ve run the script, so here’s a version that inserts the name only if it’s not already there.

    //DESCRIPTION: Insert frame names in endnotes (if they're not there already)

    (function () {
    var pos = app.activeDocument.endnoteOptions
    .endnoteSeparatorText.length+1;

    var en = app.activeDocument.stories.everyItem()
    .endnotes.everyItem().getElements();

    for (var i = en.length-1; i >= 0; i--) {
    if (en[i].characters[pos].contents !== '[') {
    try {
    en[i].insertionPoints[pos].contents =
    '[' + en[i].storyOffset.parentTextFrames[0].label + '] ';
    } catch (_) {
    }
    }
    }
    }());

     

    3 replies

    Peter Kahrel
    Community Expert
    Community Expert
    February 8, 2026

    > So if the EN was inserted in text frame “foo1”

    What is ‘foo1’ -- the name of the frame on the Layers panel?

    SuzzyFlamingo
    Inspiring
    February 8, 2026

    I was told to give the name in the script label dialog. Is that the same? For ag enius like you this should be nothing to write a scipt fo this? Right?

    Peter Kahrel
    Community Expert
    Community Expert
    February 8, 2026

    Well, never assume that a script will be a doddle. But in this case it’s pretty straightforward.

    After the script ran, check whether any notes didn’t get a frame reference. A miising frame reference means (most probably) an end note reference in overset text.

    (function () {
    var pos = app.activeDocument.endnoteOptions
    .endnoteSeparatorText.length+1;

    var en = app.activeDocument.stories.everyItem()
    .endnotes.everyItem().getElements();

    for (var i = en.length-1; i >= 0; i--) {
    try {
    en[i].insertionPoints[pos].contents =
    '[' + en[i].storyOffset.parentTextFrames[0].label + '] ';
    } catch (_) {
    }
    }
    }());

     

    Mike Witherell
    Community Expert
    Community Expert
    February 8, 2026

    A complicated workaround here:

     

    Mike Witherell
    FRIdNGE
    February 7, 2026

    Try Claude, Deepseeck, Kimi …