in reply to Re: How do I append more than one files?
in thread How do I append more than one files?

Strange things can happen if you want to copy binary files this way and forget the /B before the first argument (copy will stop at the first \cd). So:

copy /b path\to\file1 + path\to\file2 + path\to\file3 path\to\newfile

Replies are listed 'Best First'.
Re^3: How do I append more than one files?
by thor (Priest) on Jun 16, 2004 at 12:12 UTC
    Strange things can happen if you want to copy binary files this way and forget the /B before the first argument (copy will stop at the first \cd)
    The solutions given so far will not deal with that, either. In a binary file, you're not at all guaranteed to have a newline. This (untested) code should work in the general case:
    use warnings; use strict; open(my $out, ">", shift(@ARGV) ) or die $!; my $buffer_length = 16_384; while( my $file = shift(@ARGV) ) { open(my $fh, $file) or die $!; while( read($fh, my $buffer, $buffer_length) ) { print $out $buffer or die $!; } close $fh; } close $out or die $!;
    Season to taste.

    thor