Glad that I could help.
My question is, is this just excessive logging for logging’s sake or is this actually useful - as in will anyone ever look at 20k files of logging.
Maybe you can change this by not removing files only when you are running out of memory but make it some kind of FiFo with a (reasonable) limit of files kept. That way you can keep your approach with DirReadEx, iterating over only a few (10? 20? 100?`- anything far from the current 20k files).
Benefit should be reduced wear on the storage, easier manual navigation when using the logfiles for anything, easier automated handling of them, …
Best regards