Last active
August 29, 2015 14:21
-
-
Save wolffc/50b42eb086fd8b100e8c to your computer and use it in GitHub Desktop.
find dublicate files in the current directory using md5 hashes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = array(); | |
$directoryHandle = dir(__DIR__); | |
$path = $directoryHandle->path .'/'; | |
while (false !== ($entry = $directoryHandle->read())) { | |
if(is_file($path.$entry) && substr($entry, 0) !== '.'){ | |
$hash = md5_file($path.$entry); | |
$data[$hash][] = $path.$entry; | |
} | |
} | |
foreach ($data as $hash=>$files) { | |
if (count($files) >1){ | |
echo ' '. $hash . PHP_EOL; | |
foreach($files as $f){ | |
echo ' ' .$f . PHP_EOL; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment