Hiya Herwig,
Doesn't look very difficult and resembles REXX code that I have created in PDFMergeNX for "direct" distilling (without using ePDF).
However I need to check what several details in the script do exactly as my shell script knowledge is rather

Any questions see me on IRC

the other problem(?) is that ghostscript needs to be able to accept input on stdin, and the output will go to stdout - I don't know if this is a problem or not??