How to install a script in Adobe InDesign
Create a new document with a plain text editor such as "ESTK" ExtendScript Toolkit, which is part of the InDesign installation.
On the Mac, the Adobe installer buries ESTK deep within nested folders:
On Windows it is in the Start menu:
ExtendScript Toolkit will start with a blank document.
Copy-paste the whole script into that document. Include the starting comment, any "#target" mark and so forth. The script might end with strange characters such as ">})();" - these are also important.
Within ESTK there is a triangle "Run" button, give the script a try there before you store it away.
Save the script file as "myFancyScript.jsx" - the extension ".jsx" is important.
Startup scripts are found by name of the enclosing folder "Startup Scripts" which must be located two levels deep into the "scripts" folder. The folder name in between is your choice.