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.

7 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” 🙁

  2. Thank you!

    I had to run separate commands for each thumb size because without specificity, random originals also were deleted for some reason.

    find . -name *-*56×56.jpg | xargs rm -f
    find . -name *-*125x*.jpg | xargs rm -f
    find . -name *-*150x*.jpg | xargs rm -f
    find . -name *-*200x*.jpg | xargs rm -f
    find . -name *-*250x*.jpg | xargs rm -f
    find . -name *-*400x*.jpg | xargs rm -f
    find . -name *-*768x*.jpg | xargs rm -f
    find . -name *-*940x*.jpg | xargs rm -f
    find . -name *-*1024x*.jpg | xargs rm -f
    find . -name *-*2000x*.jpg | xargs rm -f

  3. I had to add quotes around the expression to make it work. Thanks for the snippet.
    find ./ -name “*-*x*.jpg”
    find ./ -name “*-*x*.jpg” | xargs rm -f

  4. Hi

    Using : find . -name *-*x*.jpg | xargs rm -f is very dangerous because it can mach original images! That’s what happened to mo… 🙁

    Exemple (french), those originals images were deleted:


    Try this to list:
    find . -regextype posix-extended -regex ‘.*\-[0-9]{1,5}x[0-9]{1,5}\.jpe?g$’

    Then to delete:
    find . -regextype posix-extended -regex ‘.*\-[0-9]{1,5}x[0-9]{1,5}\.jpe?g$’ -delete

Leave a Reply

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