I gave some consideration to the notion that a script will be located within the project in a predictable folder under its internal UUID, but what is not predictable, nor obtainable, is the path to the project itself.
My main issue with the idea you bring up is two-fold: you always get a compile folder (it’s nice when you need one, but not if you really don’t), and if you aren’t intimately aware of all the processes involved here, the result would be terribly mysterious. What is this geek code that keeps coming out of Scrivener when I compile? Do I have a virus? I think it’s a fair point, since the whole idea here is to package up these more complex implementation into easy to use Formats. Overall it just feels a bit messy to me for this particular purpose (leaving aside the whole: exporting support files in general conversation).
Another idea is an approach similar to Cover images, whereby you can select a script from a dropdown menu an alternative to typing in someting in the path field. Problem there is: what’s a script? Any text item in the binder? That could make for a massive and 99.9% useless dropdown menu. “Research” files with certain extensions? The Mac doesn’t have a convenient umbrella “Kind” for them, rather they are all identified by language, and using inconsistent nomenclature at that: “Ruby source”, “Shell script”, “Python Source”, “Lua Source File”… at least with the Cover dropdown we have an “Image Document” kind, that handles everything that is valid for selection. So that one doesn’t strike me as a good alternative either. I don’t know about you, but I’d rather type in a few dozen characters into a field than spending five minutes poking through a 1,000 item dropdown.
The best idea I’ve enccountered is something I’ve seen done in a similar situation. Hazel, the Mac folder and file automation tool, has the ability to embed a script right into the settings as an alternative to pointing to one on the disk. In the Processing pane, a radio selection could allow one to select between typing in a path and embedding a script. The embed option would have a button that loads a popup editor (hazel has fancy language detection and syntax highlighting, so maybe there is a library out there that could do that). The script is stored within the project as a file, rather than embedded into the compile XML, and in fact using this approach internally sets the path to /path/to/project/settings/<FORMAT_UUID>-compile_script.
In the context of the script being used here to split a draft into multiple parts, I would consider automating that process. The script stores an array of .tex filenames in the first loop. From that one can easily assemble a master .tex file from this array, between the first and second loops.
Now if you change a chapter name, or shuffle things in the binder, you don’t have to go back and update this master file each and every time.