As nothing seems to be forthcoming, I'm posting my stopgap solution, which demonstrably works, although not in a manner I'd wished.
Put the code into text file, change the working directory to where your .ORG files are, run the text file with the Bourne shell of your choice (BASH).
It will search for all .ORG files named by the pattern two numbers, not a number, something else, .org, then sort the names and merge the files into one .org file, removing SETUPFILE directive from all of those after the first one, and removing TOC directives from all but the 'real' TOC file (named two numbers, toc, .org).
There's some duplicated AWK code there, but I just didn't want to spend more time on this.
#! /bin/sh ttt="omg.org" # the final ORG file ddd="${PWD}/_tmp" mkdir -p "${ddd}" nnn="${ddd}/${ttt}" rm "${nnn}" # some naming conventions # two numbers and toc ending with .org # signifies TOC-containing file # which shouldn't be purged # the result goes into toc_if_any var toc_if_any=` find . -maxdepth 1 -name '*.org' \ | grep -E '//?[0-9][0-9][^0-9][^/]+$' \ | grep -E '([0-9][0-9]toc\.org)' \ | sort \ | head -n1 ` find . -maxdepth 1 -name '*.org' \ | grep -E '//?[0-9][0-9][^0-9][^/]+$' \ | sort \ | xargs -I [] \ \ sh -c " echo Doing \"[]\" this_is_toc=0 [ -n \"${toc_if_any}\" -a -f \"${toc_if_any}\" ] && ( echo \"[]\" | grep -E --quiet '[0-9][0-9]toc\.org\$' ) && this_is_toc=1 # reference with \$ ( 2>/dev/null 1>/dev/null grep -E -i '^#\\+setupfile' \"${nnn}\" && ( cat \"[]\" \ | awk -v this_is_toc=\$this_is_toc 'BEGIN {IGNORECASE=1 ; print \"\\n# !!! []\\n\"; } /^#\\+(setupfile)/ {next} /^#\\+(toc)/ { if (1 != this_is_toc) next } // {print \$0} ' \ >> \"${nnn}\" ; exit 0 ) ) || ( cat \"[]\" \ | awk -v this_is_toc=\$this_is_toc 'BEGIN {IGNORECASE=1 ; print \"# !!! []\"; } /^#\\+(toc)/ { if (1 != this_is_toc) next } // {print \$0} ' \ >> \"${nnn}\" ) "
#+SETUPFILE:lines in all the included files.findandsed(on Linux or other *nix systems) or using Emacs search and replace facitilities