I've had to deal with that very issue
here. I gave a pretty decent solution
here, in the same thread. The solution given is the solution currently used in a very large bank for processing a ton of various files coming in from various sources (some controlled, some not) onto various OS's. Give it a whirl!
------
We are the carpenters and bricklayers of the Information Age.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.