Perhaps look at the
GetFileName plugin to see how it knows when to store the one-true original file name? It must have the book id when it does it.
Perhaps store the original file name as a property in the output? I think both PDF and EPUB support custom properties.