Generalize the file filtering somewhat