This explains how to add commands like the one in my post to your toolbars and menus: How to add buttons from this forum to your toolbars.
Since you won't have tried the command yet, I recommend trying it as-is and doing the other steps manually at first, just to make sure the process does what you need it to do. If it does then we can automate it into a single-click button. If it doesn't, it will be much easier to work out what needs to change when you've been able to observe the steps individually (especially as the fully automated version could delete some files you don't want deleted).