Removing all files matching *.30×30.jpg would not delete any needed files?
If the server is Linux and you have terminal access, cd to the right folder, then rm *.30x30.jpg
Files can be removed with custom PHP code. For example, place this in a new .php file and upload to /wp-content/:
<?php // deletes all files matching uploads/2021/01/*.30x30.jpg
array_map('unlink', glob("uploads/2021/01/*.30x30.jpg"));
I recommend backing up an entire folder before running code on it just in case more gets removed than you intend.
No not all 30×30 files.
You need to check like I said
There are 6-7 sizes for each filename
You can’t be sure what’s there
Use glob() to get a list of all .jpg files in a directory. Search through the list with preg_grep() to find files like *-30×30.jpg. For each one found, see if there is a corresponding *.jpg full size file. If not found, unlink the current file and those similar. Use regular expressions to locate specific name formats and to capture the full size name portion. Regular expressions can be tricky to define. Use a site like regexr.com to test out your regexp on various samples of file names.
If a lot of files exist in a directory, this can be pretty time consuming. Either adjust the regexp to limit how many files are processed at once, and/or extend the time allowed to execute PHP with something like ini_set('max_execution_time', 120); // default=30
this is going into php programming right?
it’s a bit beyond me !
Yeah, PHP coding. If that doesn’t work for you, maybe try one of the plugins that regenerates images after the registered image sizes change. I somehow doubt they’ll flat out remove unneeded files though. Plugin authors are wary of writing code that deletes files without a very good reason. Or maybe there’s some sort of site cleanup plugin that will do what you need. It’s likely your search skills are as good as mine if not better. Sorry I can’t suggest anything more specific.