summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2012-03-09 21:22:05 +0000
committerLars Wirzenius <liw@liw.fi>2012-03-09 21:22:05 +0000
commit5ca77b7816a34fa934c8ca3cb857cf66bc986c44 (patch)
tree62326cfba872f5b2e3e3f1ca1446d80de09f75d1
parent48def64e807f3d811993cb3c733b4d71c077336d (diff)
downloaddupfiles-5ca77b7816a34fa934c8ca3cb857cf66bc986c44.tar.gz
Add --no-act option
-rwxr-xr-xdupfiles8
1 files changed, 7 insertions, 1 deletions
diff --git a/dupfiles b/dupfiles
index 951cbb2..ad189a8 100755
--- a/dupfiles
+++ b/dupfiles
@@ -203,6 +203,9 @@ class Dupfiles(cliapp.Application):
self.settings.boolean(['progress'], 'report progress')
self.settings.boolean(['remove'],
'remove all but one copy of identical files')
+ self.settings.boolean(['no-act', 'dry-run', 'pretend'],
+ 'do not really remove, just report what would '
+ 'be removed')
def process_args(self, args):
dupfinder = DuplicateFileFinder(self.settings['progress'])
@@ -236,7 +239,10 @@ class Dupfiles(cliapp.Application):
def remove_all_but_one(self, duplicates):
keep = duplicates.pop()
for pathname in duplicates:
- os.remove(pathname)
+ if self.settings['no-act']:
+ self.output.write('rm %s\n' % pathname)
+ else:
+ os.remove(pathname)
def report(self, duplicates):
sys.stdout.write('\n'.join(duplicates))