Created
July 25, 2015 12:31
-
-
Save xavery/e7e52ae22b5d5e2db5ac to your computer and use it in GitHub Desktop.
A script that removes duplicate files in its working directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use File::Find; | |
use Digest::file qw(digest_file_hex); | |
use Cwd; | |
my %sums; | |
my @dups; | |
sub wanted | |
{ | |
return unless -f $_; | |
my $sha = digest_file_hex($_, "SHA-256"); | |
if(defined($sums{$sha})) { push @dups, $File::Find::name; } | |
else { $sums{$sha} = 1; } | |
} | |
find(\&wanted, getcwd); | |
unlink @dups; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment