Created
December 31, 2016 17:06
-
-
Save pingyen/6732bb50375c4d1ad67332a13625ca87 to your computer and use it in GitHub Desktop.
iOS Duplicate Photos Finder
This file contains 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 | |
$map = array(); | |
$base = '/path/to'; | |
foreach (scandir($base) as $file) { | |
if ($name[0] === '.') { | |
continue; | |
} | |
$key = call_user_func(function($file) { | |
$pos = strpos($file, ' '); | |
if ($pos === false) { | |
return $file; | |
} | |
$pos2 = strrpos($file, '.'); | |
if ($pos2 === false) { | |
return substr($file, 0, $pos); | |
} | |
return substr($file, 0, $pos) . substr($file, $pos); | |
}, $file); | |
if (isset($map[$key]) === false) { | |
$map[$key] = array(); | |
} | |
$ref =& $map[$key]; | |
$size = filesize("$base/$file"); | |
isset($ref[$size]) === true ? | |
$ref[$size][] = $file : | |
$ref[$size] = array($file); | |
} | |
echo '<pre>', print_r($map, true), '</pre>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment