<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.antiperfect.org/index.php?action=history&amp;feed=atom&amp;title=CheckDuplicates</id>
	<title>CheckDuplicates - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.antiperfect.org/index.php?action=history&amp;feed=atom&amp;title=CheckDuplicates"/>
	<link rel="alternate" type="text/html" href="https://wiki.antiperfect.org/index.php?title=CheckDuplicates&amp;action=history"/>
	<updated>2026-10-18T03:54:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://wiki.antiperfect.org/index.php?title=CheckDuplicates&amp;diff=866&amp;oldid=prev</id>
		<title>Hdridder at 10:21, 29 June 2020</title>
		<link rel="alternate" type="text/html" href="https://wiki.antiperfect.org/index.php?title=CheckDuplicates&amp;diff=866&amp;oldid=prev"/>
		<updated>2020-06-29T10:21:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:21, 29 June 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l2&quot;&gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Python]] script to check for files with the same content.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Python]] script to check for files with the same content.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;lang=python&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#!/usr/bin/env python3&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#!/usr/bin/env python3&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-i3a:diff:1.41:old-865:rev-866:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Hdridder</name></author>
	</entry>
	<entry>
		<id>https://wiki.antiperfect.org/index.php?title=CheckDuplicates&amp;diff=865&amp;oldid=prev</id>
		<title>Hdridder: Created page with &quot;Category:Python Python script to check for files with the same content.  &lt;syntaxhighlight&gt; #!/usr/bin/env python3  def usage():     print (&quot;Usage: &quot;+__file__ +&#039;&lt;direct...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.antiperfect.org/index.php?title=CheckDuplicates&amp;diff=865&amp;oldid=prev"/>
		<updated>2020-06-29T10:21:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/index.php?title=Category:Python&quot; title=&quot;Category:Python&quot;&gt;Category:Python&lt;/a&gt; &lt;a href=&quot;/index.php?title=Python&quot; title=&quot;Python&quot;&gt;Python&lt;/a&gt; script to check for files with the same content.  &amp;lt;syntaxhighlight&amp;gt; #!/usr/bin/env python3  def usage():     print (&amp;quot;Usage: &amp;quot;+__file__ +&amp;#039;&amp;lt;direct...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Python]]&lt;br /&gt;
[[Python]] script to check for files with the same content.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
&lt;br /&gt;
def usage():&lt;br /&gt;
    print (&amp;quot;Usage: &amp;quot;+__file__ +&amp;#039;&amp;lt;directory&amp;gt;&amp;#039;)&lt;br /&gt;
    print(&amp;quot;Check for duplicate files using their hash&amp;quot;)&lt;br /&gt;
    version = &amp;#039;R1A, 19620224, Initial release&amp;#039;&lt;br /&gt;
    print(&amp;quot;Version: &amp;quot;+version)&lt;br /&gt;
    sys.exit(1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# USER CONFIGURABLE ITEMS&lt;br /&gt;
&lt;br /&gt;
BLOCKSIZE = 2**16&lt;br /&gt;
&lt;br /&gt;
# END USER CONFIGURABLE ITEMS, DO NOT CHANGE ANYTHING BELOW THIS LINE&lt;br /&gt;
&lt;br /&gt;
import os&lt;br /&gt;
import sys&lt;br /&gt;
import hashlib&lt;br /&gt;
from collections import defaultdict&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    hashset = set ()&lt;br /&gt;
    duphashes = set()&lt;br /&gt;
    filedict = defaultdict(list)&lt;br /&gt;
    if len(sys.argv) &amp;lt; 2:&lt;br /&gt;
        usage()&lt;br /&gt;
    for directory, subdirs, filenames in os.walk(sys.argv[1]):&lt;br /&gt;
        for filename in filenames:&lt;br /&gt;
            filepath = &amp;#039;/&amp;#039;.join([directory,filename])&lt;br /&gt;
            if os.path.isfile(filepath):&lt;br /&gt;
                filehash = get_hash(filepath)&lt;br /&gt;
                filedict[filehash].append(filepath)&lt;br /&gt;
                if filehash in hashset:&lt;br /&gt;
                    duphashes.add(filehash)&lt;br /&gt;
                hashset.add(filehash)&lt;br /&gt;
    for filehash in duphashes:&lt;br /&gt;
        for filename in filedict[filehash]:&lt;br /&gt;
            print(filename)&lt;br /&gt;
        print(&amp;#039;\n&amp;#039;)&lt;br /&gt;
        &lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def get_hash(filespec):&lt;br /&gt;
    hasher = hashlib.sha256()&lt;br /&gt;
    with open(filespec, &amp;#039;rb&amp;#039;) as fh:&lt;br /&gt;
        buf = fh.read(BLOCKSIZE)&lt;br /&gt;
        while len(buf) &amp;gt; 0:&lt;br /&gt;
            hasher.update(buf)&lt;br /&gt;
            buf = fh.read(BLOCKSIZE)&lt;br /&gt;
         &lt;br /&gt;
    return hasher.hexdigest()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
main()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hdridder</name></author>
	</entry>
</feed>