In MSDOS, it's very easy to get a list of files with a restriction in the name, for example its suffix.
dir *.txt
and you can send the result to an output stream other than the screen, for example, a file
dir *.txt > results.txt
I already know how to use the olden Macintosh file retrieval...