PHP code to remove duplicate image files

WBOY
Release: 2016-07-25 08:55:37
Original
1296 people have browsed it
  1. /**

  2. * Remove duplicate image files
  3. * by bbs.it-home.org
  4. */
  5. exec("find . -type f", $lines);

  6. $arr = array();

  7. $del = array();

  8. $n = 0;

  9. foreach($lines as $line){
  10. $line = trim($line);
  11. if(!$line){
  12. continue;
  13. }
  14. $n ++;
  15. $md5 = md5_file($line);

  16. if(isset($arr[$md5])){

  17. $del[] = $line;
  18. //echo "$n del $linen";
  19. unlink("{$line}");
  20. }else{
  21. $arr[$md5] = 1;
  22. }
  23. }

  24. echo "del " . count($del) . " filesn";

  25. //echo join("n", $del);

复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template