summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-12-22 09:04:38 +0000
committerLars Wirzenius <liw@liw.fi>2010-12-22 09:04:38 +0000
commit9a0b263b7fc9d43e6acd16729ebfc2120ae501d6 (patch)
tree867662e876c2c77ca123cc708527819bce6ce634
parente6657c0fe65e4c99e948fa9b38a94499ff2a1af8 (diff)
downloaddupfiles-9a0b263b7fc9d43e6acd16729ebfc2120ae501d6.tar.gz
Add --remove option.
-rw-r--r--debian/changelog6
-rwxr-xr-xdupfiles10
-rw-r--r--dupfiles.16
3 files changed, 21 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index df2a680..76a87d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+dupfiles (5.1) squeeze; urgency=low
+
+ * Add --remove option.
+
+ -- Lars Wirzenius <liw@liw.fi> Wed, 22 Dec 2010 09:04:17 +0000
+
dupfiles (5) squeeze; urgency=low
* Use python-ttystatus for progress reporting.
diff --git a/dupfiles b/dupfiles
index 8c06c3d..3d9e8db 100755
--- a/dupfiles
+++ b/dupfiles
@@ -197,6 +197,12 @@ def make_hardlinks(duplicates):
os.link(canonical, pathname)
+def remove_all_but_one(duplicates):
+ keep = duplicates.pop()
+ for pathname in duplicates:
+ os.remove(pathname)
+
+
def report(duplicates):
sys.stdout.write('\n'.join(duplicates))
sys.stdout.write('\n\n')
@@ -208,6 +214,8 @@ def main():
help='hardlink duplicate files to each other')
parser.add_option('--progress', action='store_true',
help='report progress')
+ parser.add_option('--remove', action='store_true',
+ help='remove all but one copy of identical files')
opts, args = parser.parse_args()
@@ -218,6 +226,8 @@ def main():
for duplicates in dupfinder.duplicates():
if opts.make_hardlinks:
make_hardlinks(duplicates)
+ elif opts.remove:
+ remove_all_but_one(duplicates)
else:
report(duplicates)
diff --git a/dupfiles.1 b/dupfiles.1
index 1bcf159..ee66d9b 100644
--- a/dupfiles.1
+++ b/dupfiles.1
@@ -20,6 +20,7 @@ dupfiles \- find identical files and optionally hardlink them
.B dupfiles
.RB [ --make-hardlinks ]
.RB [ --progress ]
+.RB [ --remove ]
.RI [ file ]...
.SH DESCRIPTION
.B dupfiles
@@ -43,7 +44,10 @@ Report progress while program is running.
.BR --make-hardlinks
Instead of reporting files that have been found,
make sure all names point at the same content.
-FIXME.
+.TP
+.BR --remove
+Remove all but one copy of identical files.
+The copy that gets kept is chosen arbitrarily.
.SH EXAMPLE
To find all duplicate packages in Debian and Ubuntu:
.IP