ermig1979 / AntiDupl

A program to search similar and defect pictures on the disk
https://ermig1979.github.io/AntiDupl
MIT License
1.23k stars 92 forks source link

Search for duplicates only within the same folder/directory not working properly. #173

Open kamikaze00007 opened 1 year ago

kamikaze00007 commented 1 year ago

I have tried using both, and either just one of the Options for "Compare images inside one directory" and "Compare images from one path of search with one another". However, I cannot seem to be able to narrow down my duplicate search into strictly duplicate images that are in the same folder. Is this normal?

For context, I'm trying to organize comic book folders that are separated by chapters. An example is: J:\Downloads\Batman Ninja\Chapter 001 J:\Downloads\Batman Ninja\Chapter 002 J:\Downloads\Batman Ninja\Chapter 003 J:\Downloads\Batman Ninja\Chapter 004 and so on...

What I want to happen is to have the program to look for duplicate images ONLY INSIDE THE SAME CHAPTER FOLDER.

The issue for example: J:\Downloads\Batman Ninja**Chapter 001\cover.jpg** J:\Downloads\Batman Ninja\Chapter 001\001.jpg

J:\Downloads\Batman Ninja**Chapter 002\cover.jpg**

The program detects Chapter 001 and Chapter 002's "cover.jpg" as duplicates regardless of whatever Compare setting I use to narrow down comparison inside one directory. The results end up pointing to both images on those separate folders. This results with me losing the cover page for Chapter 002, although yes, the cover page are the same per chapter, but this breaks the flow of pages as a result.

I may just be not using the program properly, so please educate me how to do so if that's the case. But I would like it if the program could just search duplicates only inside the same chapter folder. Like, if cover.jpg and 002.jpg inside ONLY Chapter 001 folder are the same images, the results narrow the result comparison that way.

apturtia commented 3 months ago

Just ran into the same issue. I'm not expert in .Net, but to me it seems that comparison logic is backwards:

bool TImageComparer::IsDuplPair(TImageDataPtr pFirst, TImageDataPtr pSecond, double *pDifference)
{
[...]
    if(m_pOptions->compare.compareInsideOneFolder == FALSE && TPath::EqualByDirectory(pFirst->path, pSecond->path))
        return false;

    if(m_pOptions->compare.compareInsideOneSearchPath == FALSE && pFirst->index == pSecond->index)
        return false;

If TPath::EqualByDirectory returns true, the IsDuplPair returns false.

Same for pFirst->index == pSecond->index. It the indexes are the same, IsDuplPair returns false.

Those two conditions seem to be missing the negation.