I also have the same problem for international website using moodle. I want to leave access to everybody but not to spammers.
I see you problem is already an old issue, did you find a solution? I had a look at all answers but didn't really find a solution.
I would need the feature you suggested: filtering and deleted all users not enrolled in any course. please let be know how to do this with bulk user action. As I have over 2000 accounts to delete, I cannot do it manually.
For my other website, the accounts are linked with Joomdle for other purposes. In this regard some users might not be enrolled in any course but still legitimate users. So, another common feature from the spammers are that they let a website adress on their profile account. Is there a way to select all users that left the website not blank and delete those accounts?
I hope you could find a solution by the time and look forward for your support.