I have created script which will delete images by size name.
Put php file with below code in your home directory and call it from web browser!
So for example if you want to delete all images with size "home_default" add to private $files = array() only this file size:
<?php
require(dirname(__FILE__).'/config/config.inc.php');
new deleteImages();
class deleteImages {
private $files = array(
'home_default'
);
private $imgDir = 'img/p';
function __construct() {
$this->directoryToArray($this->imgDir);
}
public function directoryToArray($directory, $recursive = true, $listDirs = false, $listFiles = true, $exclude = '') {
$arrayItems = array();
$skipByExclude = false;
$handle = opendir($directory);
if ($handle) {
while (false !== ($file = readdir($handle))) {
preg_match("/(^(([\.]){1,2})$|(\.(svn|git|md))|(Thumbs\.db|\.DS_STORE))$/iu", $file, $skip);
if($exclude){
preg_match($exclude, $file, $skipByExclude);
}
if (!$skip && !$skipByExclude) {
if (is_dir($directory. DIRECTORY_SEPARATOR . $file)) {
if($recursive) {
$arrayItems = array_merge($arrayItems, $this->directoryToArray($directory. DIRECTORY_SEPARATOR . $file, $recursive, $listDirs, $listFiles, $exclude));
}
if($listDirs){
$file = $directory . DIRECTORY_SEPARATOR . $file;
$arrayItems[] = $file;
}
} else {
if($listFiles){
$file = $directory . DIRECTORY_SEPARATOR . $file;
foreach($this->files as $fileD) {
if(strpos($file, $fileD) !== false) {
unlink($file);
}
}
$arrayItems[] = $file;
}
}
}
}
closedir($handle);
}
return $arrayItems;
}
}
?>