I'm not familiar with the conversion issues, and this is just a quick idea of the top of my head, but it seems likely your script may be slow because it's reading and processing the input a line at a time. So, can you work with the input as a whole file?
E.g., copy input to a temp file, apply the file command to that to determine what type it is, then cat the tempfile through the conversion filter or not, as you've done with lines. Then delete the tempfile.
There's probably a neater version of this, which might be worth looking for if this method works at all and gives a good speedup. Hope that helps.
|