Removing auto-generated WordPress thumbnail images

If you have folders full of intermediate thumbnail sizes that you don’t want, you can easily select and delete all the thumbnails WordPress has generated using the right tools. This is particularly useful if you change thumbnail sizes and want to get rid of old images.

If you have a Mac, use ‘Find Any File‘ and use a regex pattern to search for images: -(\d{2,4})x(\d{2,4})\.(jpg|jpeg|png|gif)

The regex will select file names that end with a dash followed by thumbnail width by thumnbmail height and the usual image file name extensions. This is the standard WP thumbnail naming format.

‘Find Any File’ will give you a window of images and you can manage/delete as you want.

If you type an incorrect regex (search) string in, the app will helpfully flag the error:

If you have repeatedly imported a test file into a development server, this may leave you with a number of additional duplicate full-size images in your uploads folder – the regex above will not remove these though.

This string has found a lot of duplicates for me – but not all – but be aware that it may select images that you don’t want, depending on their naming format: (\d)-(\d)\.(jpg|jpeg|png|gif)

TIP:

When you import a test file of WP posts (etc.) into a development server create a new Uploads folder each time you do a test import. This avoids the problem of having duplicate original files.

What do you think?

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.