How can this python regex file finder be improved?
I think a regex is overkill here. There comes a point where evaluating all these or'ed exceptions becomes just too slow. I would instead use a simple glob and a blacklist:
from pathlib import Path

IGNORE = {&quot;absolute&quot;, &quot;abstract&quot;, ...}

root = Path(&quot;/ROOTDIRECTORY&quot;)
for file in root.glob(&quot;**/*.php&quot;):
    if len(file.stem) == 8 and file.stem not in IGNORE:
        print(file)

Note that I used a set for a fast check with in.
You could also use the glob &quot;**/????????.php&quot;, as suggested by @RootTwo in the comments, then you wouldn't have to do the length check, although that is quite fast.
Indeed, what you should ideally do is not take my or anyone else's word for it, but measure. Measure how fast your approach is, how fast an optimized regex is, how fast mine is and how fast using a different glob is. Maybe it matters, or maybe all of this is premature optimization and it doesn't actually matter that one takes a millisecond and the other a second (or whatever the actual results are). That depends entirely on your use case.