How to Delete all WordPress-generated Thumbnail Sizes

After changing the registered thumbnail sizes and regenerating your thumbnails a few times during theme development, you may have quite a few thumbnails left over from old images sizes that don’t match any of the currently registered sizes, but are just sitting there in your uploads directory taking up space. Here is a command which will delete all generated thumbnails, after which you can regenerate your thumbnails one final time and be left with only the sizes currently registered in the theme.

Navigate to your uploads directory, and run this command:
find . -name *-*x*.jpg | xargs rm -f

Note that this will delete ALL generated thumbnails, so only run this if that’s what you want. The originals will be unaffected, unless they are named like a thumbnail.

3 thoughts on “How to Delete all WordPress-generated Thumbnail Sizes

  1. Thanks! I kept googling two days for a solution to reduce the number of files in my uploads folder (over 58.000 images) and thought I finally found an answer, but when I copy this into Putty it says: “-bash: /bin/find: Argument list too long” 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *