Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
file duplicate finder
<?php
declare(strict_types=1);
$dir='C:\Users\hans\Downloads\penis\penis2\JYTTE';
if(!chdir($dir)){
die("ERROR: FAILED TO CHDIR");
}
$files_raw=glob("*",GLOB_NOSORT);
$files=array();
$duplicate_counter=0;
foreach($files_raw as $file){
$file=realpath($file);
$hash=hash_file("md5",$file,false);
if(isset($files[$hash])){
echo "DUPLICATE FOUND: \"{$files[$hash]}\" IS A DUPLICATE OF \"{$file}\"\n";
++$duplicate_counter;
}
$files[$hash]=$file;
}
var_dump($files);
echo "total duplicates: ";
var_dump($duplicate_counter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.