Skip to content

Instantly share code, notes, and snippets.

@pingyen
Created December 31, 2016 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingyen/6732bb50375c4d1ad67332a13625ca87 to your computer and use it in GitHub Desktop.
Save pingyen/6732bb50375c4d1ad67332a13625ca87 to your computer and use it in GitHub Desktop.
iOS Duplicate Photos Finder
<?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