SuperMonkey

Remove duplicates

Jun 4th, 2014
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.28 KB | None | 0 0
  1. <?php // removes duplicated files in a dir
  2.  
  3. $dir = scandir(".");
  4. $_md5 = array();
  5.  
  6. foreach($dir as $i=>$file) {
  7.     if($file == "." || $file == "..") continue;
  8.  
  9.     $md5 = md5(file_get_contents($file));
  10.     if(!in_array($md5, $_md5)) {
  11.         $_md5[] = $md5;
  12.     } else {
  13.         unlink($file);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment