I remember, there was a fine set of C functions on PC: _dos_findfirst and _dos_findnext. Names slightly differ from compiler to compiler.With their help it was very easy to process set of files with names, matching certain criteria.
The way I approached this was by combining the opendir(), readdir(), closedir() APIs with the regular expression APIs regcomp(), regexec(), regfree().
I used this to write wrappers called IFS_opendir(), IFS_readdir(), etc. You call those routines and provide a directory name and a regular expression and they read only the matching filenames from the directory.
I wrote my code in ILE RPG, but there's nothing that stops you from doing the same thing in ILE C.
Mine were written for an article entitlted "IFS Directory Listing with Wildards", and if you have a Pro membership with the iSeries Network, you can read it at the following link: