How to remove all WordPress generated thumbnails
I came across an article which listed a simple solution:
find . -iname '*-*x*.jpg' | xargs rm -f
This is however, not good, because as you can see the regex will look for any file with a dash, which can result in some wrong file deletions – yikes.
A better way to go about this is:
find . -name '*[0-9]x[0-9]*.*' | xargs trash
This is a little more specific without getting too crazy, it was enough for me to have zero wrong file deletions. It works for more than one file type so you don’t have rerun it for each one. This is also non-destructive, items go to the trash where they can be recovered, assuming you have a trash cli.