Find duplicates search comparison plugin

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
mikedepetris
Junior Member
Junior Member
Posts: 84
Joined: 2006-11-07, 16:36 UTC
Location: Trieste, Italy
Contact:

Find duplicates search comparison plugin

Post by *mikedepetris »

I need somebody to help me finding the better way to achieve my goal.
I need to identify (and then often delete or move) files that are "smaller/previous versions", this happens with log files that grow in time.
Example:
fileA:
Line1
Line2
fileB:
Line1
Line2
Line3
fileC:
Line1
Line2
Line3
Line4

I want to detect that fileA and fileB are "included" at the start of the text of fileC, so I can safely remove them.

My idea was to write a comparison function that returns:
0 when the files are equal in size and content (like find duplicates)
1 when at least a byte is different
2 when all bytes are equal but first file is bigger
3 when all bytes are equal but second file is bigger

How could I get to the point?
It would be enough for me to obtain a list of the files with the 0-3 values to manage with a batch file.
User avatar
Samuel
Power Member
Power Member
Posts: 1929
Joined: 2003-08-29, 15:44 UTC
Location: Germany, Brandenburg an der Havel
Contact:

Post by *Samuel »

I would use TCs compare by content or the program Winmerge to compare the files. If it is a common problems for many files, I would try to solve the problem. Otherwise the best is programming something for exact this use case. I don't think it has been done already.
mikedepetris
Junior Member
Junior Member
Posts: 84
Joined: 2006-11-07, 16:36 UTC
Location: Trieste, Italy
Contact:

Post by *mikedepetris »

I was able to write a WDX "content plugin" using the .NET wrapper, and I will try to use the method:

ContentCompareResult CompareFiles()

to compare the two log files and report the result.
Is the "ContentCompareResult" enum documented anywhere? I'm not getting the difference between:
return ContentCompareResult.EqualWithTxt;
return ContentCompareResult.EqualWithIcon;

Any help?
mikedepetris
Junior Member
Junior Member
Posts: 84
Joined: 2006-11-07, 16:36 UTC
Location: Trieste, Italy
Contact:

Post by *mikedepetris »

Anyway, the WDX does not solve the original problem, as I can't use the CompareFiles() as an input for the "same plugin fields" in the "find duplicates" function, that seems to be hardcoded in TC.

Would you suggest to write a standalone program or have you any other idea to use TC to at least provide the combinations of comparisons to do for the given search? Even if it will not show the files in TC as a result.
mikedepetris
Junior Member
Junior Member
Posts: 84
Joined: 2006-11-07, 16:36 UTC
Location: Trieste, Italy
Contact:

Post by *mikedepetris »

Conclusion I did both:

WDX content plugin:
when synchronizing gives out files equal, not equal and
left file is included in rigth file: EqualWithTxt
right file is included in left file: EqualWithIcon
--> the two icons appear equal, how should this be managed?

exe program:
recurses all directories passed as arguments
compares each file with all others line by line
return a number N followed by the two compared files, semicolon separated
N=0 means the files are equal
N=1 (optional) files are not equal
N=2 first file is included in second file
N=3 second file is included in first file
with this output it is easy to prepare a batch file to move or delete desired "duplicate" files
Post Reply