diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-03-09 21:22:05 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-03-09 21:22:05 +0000 |
commit | 5ca77b7816a34fa934c8ca3cb857cf66bc986c44 (patch) | |
tree | 62326cfba872f5b2e3e3f1ca1446d80de09f75d1 | |
parent | 48def64e807f3d811993cb3c733b4d71c077336d (diff) | |
download | dupfiles-5ca77b7816a34fa934c8ca3cb857cf66bc986c44.tar.gz |
Add --no-act option
-rwxr-xr-x | dupfiles | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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)) |