join part.001 and part.002 and part.003

I download big files from internet by torrent and these files are like these

Code:
part.001 part.002 part.003 and .... part.0035
If I use unrar , this packages can not detect this files and say this files are not rar , how I can join them ?
and which packages I can use ?
 
This will do it:
$ cat part.001 part.002 part.003 > completefile

But this will get somewhat annoying if you have 30-40 parts. To get around it I wrote a small perl script and called it mpjoin.pl:

Code:
#!/usr/bin/perl

use FileHandle;
use DirHandle;

my $arg = $ARGV[0] || die "Need an argument!\n";

if( $arg =~ m/(.*)\.\d{2,3}$/ ) { $arg = $1; }

my $dir = DirHandle->new(".");

my $fn, @files;

while( defined( $_ = $dir->read() ) ) {
        next if -d $_;
        next unless m/\Q$arg\E\.\d{2,3}$/;
        push( @files, $_ );
}

if( $#files == 0 ) {
        print "Didn't find any parts\n";
        exit(0);
}

my $of = FileHandle->new("$arg","w");

foreach $fn (sort @files) {
        print "$fn:";
        if( $fn =~ m/.*\.000$/ ) {
                print "Skipping\n";
                next;
        }

        my $if = FileHandle->new("$fn","r");
        while( ! $if->eof() ) {
                my $temp = $if->getline();
                print $of $temp;
        }
        print "Added\n";
}

$of->close();

Just call it like $ mpjoin.pl somefile and it will join somefile.001, somefile.002 etc. and save it as somefile.
 
SirDice said:
This will do it:
$ cat part.001 part.002 part.003 > completefile

But this will get somewhat annoying if you have 30-40 parts.

What about that?
$ cat part.* > completefile
 
SirDice said:
You can't be sure of the order ;)


Code:
% :> part.005
% :> part.002
% :> part.004
% :> part.003
% :> part.001
% echo part.*
part.001 part.002 part.003 part.004 part.005
%

... yes you can.
 
As long as the 'part generator' plays nicely .. sure. But do they all?

Code:
echo part.*
part.0 part.1 part.10 part.11 part.12 part.13 part.14 part.15 part.16 part.17 part.18 part.19 part.2 part.20 part.21 part.3 part.4 part.5 part.6 part.7 part.8 part.9
 
Well.. I did have problems with filename globbing. Not sure what it was but it was the reason I wrote the script. I think one of the problems was with a large amount of file parts.
 
mfaridi said:
if these file is AVI , dose this method work ?

As long as it's split up with those .001, .002, .003 extensions.

You cannot cat 2 avis together like mymovie-cd1.avi and mymovie-cd2.avi. You could but the indexing will get screwed up. If you want to concatenate 2 (or more) parts like that use mencoder.

$ mencoder -forceidx -ovc copy -oac copy -o mymovie.avi mymovie-cd1.avi mymovie-cd2.avi
 
all of these file is movie , this movie splite part.001 and part.002 and ...
in windows we can use program to join them
 
mfaridi said:
all of these file is movie , this movie splite part.001 and part.002 and ...
in windows we can use program to join them

In that case use my script or cat part.* > output.
 
I suggest you try - it sounds like they have just been chunked (the first MB in one file, the next MB in the next file, or whatever size the parts are), and that's exactly what cat was meant to reverse.
 
Back
Top