@jws That would work, but, if I understand your post correctly, would get messy if I ever decided to add something in the middle of the sequence — I'd have to rename all the existing files, and that goes against the LaTeX idea as well (i.e. headers are numbered automatically based on order of appearance). The aim of writing this script is to have it usable for everything I do from now on involving pandoc, so it seems like having a contents.txt that acts as the input for the commands is probably the best approach.
I've had a look for ideas from others who've scripted for pandoc and the closes I can find is pandoc-include [hackage.haskell.org], but that needs another installation, which means one more thing to remember when using the script on another computer.