I recently noticed that the Batch Manager finds its duplicates based on the original file name. This is very confusing as normally duplicated files get uploaded because they happen to have different filenames. It is much safer to determine duplicates based on the file's md5sum, which is calculated after upload and stored in the database anyway.
I have created a small patch that searches for duplicates based on the md5sum instead of filename and will attach it here.
**Reported by sakanaou on 11 Dec 2012 14:12**
**Version:** 2.4.5
I recently noticed that the Batch Manager finds its duplicates based on the original file name. This is very confusing as normally duplicated files get uploaded because they happen to have different filenames. It is much safer to determine duplicates based on the file's md5sum, which is calculated after upload and stored in the database anyway.
I have created a small patch that searches for duplicates based on the md5sum instead of filename and will attach it here.
[Piwigo Bugtracker #2801](http://piwigo.org/bugs/view.php?id=2801)
<!-- github-sync-id:97226498 -->
**Comment posted by thimo on 20 Jan 2013 16:16**
As mentioned in the forum the property "uniqueness_mode" should be incorporated:
http://piwigo.org/forum/viewtopic.php?id=20983
File /admin/batch_manager.php:
```
// perform 2 queries instead. We hope there are not too many duplicates.
```
- ```
$field = ($conf['uniqueness_mode'] == 'md5sum') ? 'md5sum' : 'file';
```
$query = '
-SELECT file
+SELECT '.$field.'
FROM '.IMAGES_TABLE.'
- GROUP BY file
- GROUP BY '.$field.'
HAVING COUNT(*) > 1
;';
- $duplicate_files = array_from_query($query, 'file');
- $duplicate_files = array_from_query($query, $field);
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
- WHERE file IN (''.implode("','", $duplicate_files).'')
- WHERE '.$field.' IN (''.implode("','", $duplicate_files).'')
;';
array_push(
And add a hash to imports from the galleries folder (file /admin/site_update.php):
```
$insert = array(
'id' => $next_element_id++,
'file' => $filename,
'name' => get_name_from_file($filename),
'date_available' => CURRENT_DATE,
'path' => $path,
'representative_ext' => $fs[$path]['representative_ext'],
'storage_category_id' => $db_fulldirs[$dirname],
'added_by' => $user['id'],
```
- 'md5sum' => md5_file($path),
);
<!-- github-comment-id:124892954 -->
Hi, based on piwigo 2.7 this could add a checkmark to find by md5sum. This also could add an option to uncheck the filename option.
**Comment posted by msakik on 11 Feb 2015 11:59**
Hi, based on piwigo 2.7 this could add a checkmark to find by md5sum. This also could add an option to uncheck the filename option.
<!-- github-comment-id:124892964 -->
So I have added a new checkbox "checksum" on the list of "find duplicates based on" options on the batch manager. The main problem is that photos added with synchronization have no md5sum (in the database, I mean), so this filter won't work for them.
We need a feature to compute checksums. I don't think it's a good idea to have these features in core, because it's only useful to very few people. ie people searching for duplicates based on checksum + using sync which is less and less used compared to other upload methods. The best idea I have now is to create a plugin "Compute Checksum" that would add features on Batch Manager:
a filter "with no checksum"
an action "compute checksum"
So I have added a new checkbox "checksum" on the list of "find duplicates based on" options on the batch manager. The main problem is that photos added with synchronization have no md5sum (in the database, I mean), so this filter won't work for them.
We need a feature to compute checksums. I don't think it's a good idea to have these features in core, because it's only useful to very few people. ie people searching for duplicates based on checksum + using sync which is less and less used compared to other upload methods. The best idea I have now is to create a plugin "Compute Checksum" that would add features on Batch Manager:
1. a filter "with no checksum"
2. an action "compute checksum"
<!-- github-comment-id:266300438 -->
What is the status of this? I would like to be able to search for duplicates of images already uploaded and have the option to delete the dupe. Even better if I could merge the tags, views, etc of both.
What is the status of this? I would like to be able to search for duplicates of images already uploaded and have the option to delete the dupe. Even better if I could merge the tags, views, etc of both.
<!-- github-comment-id:314309424 -->
I just recognized that most of my files have NULL in the md5sum field. Therefor I do not find duplicates based on md5sum. It would be cool to have an option to compute the md5sum for all pictures.
Any news on this issue?
Best regards
Jens
PS: Keep on going with the cool Piwigo software.
Hello!
I just recognized that most of my files have NULL in the md5sum field. Therefor I do not find duplicates based on md5sum. It would be cool to have an option to compute the md5sum for all pictures.
Any news on this issue?
Best regards
Jens
PS: Keep on going with the cool Piwigo software.
<!-- github-comment-id:375453124 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Reported by sakanaou on 11 Dec 2012 14:12
Version: 2.4.5
I recently noticed that the Batch Manager finds its duplicates based on the original file name. This is very confusing as normally duplicated files get uploaded because they happen to have different filenames. It is much safer to determine duplicates based on the file's md5sum, which is calculated after upload and stored in the database anyway.
I have created a small patch that searches for duplicates based on the md5sum instead of filename and will attach it here.
Piwigo Bugtracker #2801
Comment posted by thimo on 20 Jan 2013 16:16
As mentioned in the forum the property "uniqueness_mode" should be incorporated:
http://piwigo.org/forum/viewtopic.php?id=20983
File /admin/batch_manager.php:
$query = '
-SELECT file
+SELECT '.$field.'
FROM '.IMAGES_TABLE.'
GROUP BY file
GROUP BY '.$field.'
HAVING COUNT(*) > 1
;';
$duplicate_files = array_from_query($query, 'file');
$duplicate_files = array_from_query($query, $field);
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
WHERE file IN (''.implode("','", $duplicate_files).'')
WHERE '.$field.' IN (''.implode("','", $duplicate_files).'')
;';
array_push(
And add a hash to imports from the galleries folder (file /admin/site_update.php):
Comment posted by msakik on 11 Feb 2015 11:59
Hi, based on piwigo 2.7 this could add a checkmark to find by md5sum. This also could add an option to uncheck the filename option.
+1 to this request.
So I have added a new checkbox "checksum" on the list of "find duplicates based on" options on the batch manager. The main problem is that photos added with synchronization have no md5sum (in the database, I mean), so this filter won't work for them.
We need a feature to compute checksums. I don't think it's a good idea to have these features in core, because it's only useful to very few people. ie people searching for duplicates based on checksum + using sync which is less and less used compared to other upload methods. The best idea I have now is to create a plugin "Compute Checksum" that would add features on Batch Manager:
What is the status of this? I would like to be able to search for duplicates of images already uploaded and have the option to delete the dupe. Even better if I could merge the tags, views, etc of both.
Hello!
I just recognized that most of my files have NULL in the md5sum field. Therefor I do not find duplicates based on md5sum. It would be cool to have an option to compute the md5sum for all pictures.
Any news on this issue?
Best regards
Jens
PS: Keep on going with the cool Piwigo software.
@jheinitz that's right, see #272