/usr/bin/remove-duplicates is in recoverjpeg 2.6-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #! /usr/bin/python
#
# Usage: remove-duplicates
#
# Remove duplicates of the same file in the current directory if -f is
# given.
#
# If -f is not given, duplicate will be identified twice (once in every
# direction).
#
import os
def check_duplicate (orig, copy):
try:
if open(orig).read() == open(copy).read():
print "Removing %s which is a copy of %s" % (copy, orig)
os.unlink (copy)
except:
pass
def aggregate ():
d = {}
for f in os.listdir ('.'):
s = os.stat(f)[6]
if d.has_key (s): d[s].append (f)
else: d[s] = [f]
return d
def remove_duplicates (d):
for v in d.values():
while v:
del v[0]
for c in v[1:]: check_duplicate (v[0], c)
if __name__ == '__main__':
remove_duplicates (aggregate ())
|