diff --git a/fdupes_relink b/fdupes_relink deleted file mode 100644 index 95948af2..00000000 --- a/fdupes_relink +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; - -$/=""; -while (<>) { - chomp; - - my %dups; # hash: inode -> array of filenames - foreach (split /\n/) { - my $inode = (stat)[1]; - push @{$dups{$inode}}, $_; - } - - my @keys = keys(%dups); - - # all are hardlinks to the same data - next if (scalar @keys < 2); - - # sort by nlink - @keys = sort { scalar $dups{$a} <=> scalar $dups{$b} } @keys; - my $target = $dups{shift @keys}[0]; - - foreach (@keys) { - foreach (@{$dups{$_}}) { - print "relinking $_ -> $target\n"; - unlink($_); - link($target, $_) or die "link failed"; - } - } -}