OK I have 5 programs that count and list Bas files from a start Directory, they are described with a couple times I got testing the programs. Turns out when I fixed the original recursive code, it turned in the fastest times but Steve's code is checking everything which I think accounts for difference in times, more than double.
Anyway here is code and comments tested on my old Windows 10 laptop 64-bit with a Desktop containing over 11,850 files. Of course you will have different results.
PS to test in your system edit a couple of lines near the top of each program specifying the path and the pathed file list file name to use. Oh, also if direntry.h is not in the same folder as QB64.exe, there is a copy that is commented out at the bottom of programs that use it.