You can use this perl script.
$ mass-par2repair alt.binaries.*
Where arguments are directories, NOT files.
#!/usr/bin/perl -w
# Copyright (C) 2005 Anthony DeRobertis (netnews at derobert d0t net)
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this file; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
sub run_par(@);
my %results = ();
foreach my $dir (@ARGV) {
opendir DH, $dir or die “Could not open directory $dir: $!”;
my %par_files = ();
my %segment_files = ();
foreach my $file (readdir DH) {
my $base = undef;
if ($file =~ /.par2?$/i) {
if ($file =~ /^(.+)\.vol\d+\+\d+\.par2?$/i) {
$base = $1;
} elsif ($file =~ /^(.+)\.par2?/i) {
$base = $1;
} else {
die “Failed to find basename of $file.”;
}
push @{$par_files{$base}}, $file;
} elsif ($file =~ /^(.+)\.\d\d\d$/) {
$base = $1;
push @{$segment_files{$base}}, $file;
}
}
foreach my $key (keys %par_files) {
print “$key:\n “;
print join(“\n “, @{$par_files{$key}}), “\n”;
my @args = ();
foreach my $file (@{$par_files{$key}}, @{$segment_files{$key}}) {
push @args, “$dir/$file”;
}
my $retcode = run_par(@args);
if ($retcode == -1) {
die “Could not exec par2: $!”;
} elsif ($retcode == 0) {
#$results{$dir}->{$key} = ‘OK’;
print ” OK.\n\n”
} else {
$results{$dir}->{$key} = “FAILED ($retcode).”;
print ” FAILED ($retcode)\n\n”;
}
}
closedir DH;
}
print “\n\n\n”;
foreach my $dir (keys %results) {
print “SUMMARY FOR $dir:\n”;
foreach my $file (sort keys %{$results{$dir}}) {
print “\t$file: ” . $results{$dir}->{$file} . “\n”;
}
print “\n”;
}
sub run_par(@) {
my $pid = fork();
if ($pid == -1) {
return -1;
} elsif ($pid == 0) {
open STDOUT, ‘+>’, ‘/dev/null’ or die “> /dev/null failed: $!”;
exec {‘par2′} ‘par2′, ‘r’, ‘–’, @_;
die “Exec of par2 failed: $!”;
} else {
waitpid($pid, 0);
return $?;
}
}
########END OF PERL SCRIPT #############
As you noticed, I’ve messed up all the formatting but it still works. If you want the original file, contact the author, his address is in the headers.
So, to batch-repair everything in a directory you can also simply type :
for i in *.par2; do par2repair $i; done
This will work 99% of the time, since usually the first par2 file of the a set ( the smallest one ) is not capitalized, whereas the rest if them are.
To make it work 100% of the time, you can do this :
for i in *.[pP][aA][rR]2; do par2 r $i; done
But beware, this is a brutal, it will run par2repair everytime for every par2 file in the recovery set.
( thanks to the anonymous poster )
Please drop a comment if you have a question or new software to plug !

Pingback: Alt.bin » Usenet binaries with Linux tutorial