How to remove all WordPress thumbnails using command line

If you want to free up some space deleting the WordPress thumbnails you can do it via SSH in the command line.

This command deletes every thumbnail regardless if it is being used or not. You might want to use a thumbnail regenerate plugin for that.

This case here is to delete all the garbage in case you want to regenerate them or don't need them anymore.

List the files

List all the thumbnails in the current and sub-directories.

find . -iname '*-*x*.jpg' | xargs ls
Code language: JavaScript (javascript)

Delete them

You might want to have a backup in case something goes wrong.

find . -iname '*-*x*.jpg' | xargs rm -f
Code language: JavaScript (javascript)

Leave a Reply

Add <code> Some Code </code> by using this tags.