You might look at the code in the Quality Check PI: Cleanup files and folders.
Kiwidude added that at my request for my RMSDK based Astak. I don't Know what this will do on something else.
Ya know, the Fix section in this PI should really be broken out as the main thrust of the PI is to REPORT.
THEN
Solutions for some of these most excellent
repair issues could be added