When shifting through WordPress themes utilizing a variety image sizes, your wp-content/uploads or wp-content/blog.dir directories can get full of abandoned images. An easy way to get rid of those abandoned images is to delete them and then regenerate those that you actually need.
SHOW all resized images
cd /home/example/public_html/wp-content/uploads find . -regextype posix-extended -regex ".*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)" -type f cd /home/example/public_html/wp-content/blogs.dir find . -regextype posix-extended -regex ".*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)" -type f
DELETE all resized images
cd /home/example/public_html/wp-content/uploads find . -regextype posix-extended -regex ".*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)" -type f -exec rm {} ; cd /home/example/public_html/wp-content/blogs.dir find . -regextype posix-extended -regex ".*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)" -type f -exec rm {} ;
After deleting the resized media images, now you should regenerate the sizes you do need by using Regenerate Thumbnails or AJAX Thumbnail Rebuild.
Hey,
I ran your commands, but discovered a small but very important error.
The delete-lines are missing the actual deleting command, so the script will attempt to execute each file instead of deleting them.
Thus, the lines SHOULD read:
cd /home/example/public_html/wp-content/uploads
find . -regextype posix-extended -regex “.*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)” -type f -exec rm {} ;
cd /home/example/public_html/wp-content/blogs.dir
find . -regextype posix-extended -regex “.*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)” -type f -exec rm {} ;
Thank you Måns for the note. I’ve fixed the post.