PHP去除重复图片文件的代码
时间:2021-07-01 10:21:17
帮助过:25人阅读
/** - * 去除重复的图片文件
- * by bbs.it-home.org
- */
- exec("find . -type f", $lines);
$arr = array(); - $del = array();
$n = 0; - foreach($lines as $line){
- $line = trim($line);
- if(!$line){
- continue;
- }
- $n ++;
- $md5 = md5_file($line);
if(isset($arr[$md5])){ - $del[] = $line;
- //echo "$n del $line\n";
- unlink("{$line}");
- }else{
- $arr[$md5] = 1;
- }
- }
echo "del " . count($del) . " files\n"; - //echo join("\n", $del);
|