> Thanks to Rick Quatro I now have a working script.
I didn't solve the problem with my script, btw. Rick provided me with a working 'shell' script for processing all the files in a book, so I used that method instead of my initial idea to process all the files in a directory. Harro de Jong