#!/usr/bin/perl

my($this,$that,$oac,$ovc)=('','reidx.avi','copy','copy');

my $argv0=$ARGV[0]; print "$argv0*\n";

foreach((scalar @ARGV>1 or -r $argv0)? sort @ARGV:sort glob("$argv0*"))
{
 $this.=" \"$1.mpg\""             if(/^(.*[^_])\.mpg$/);
 $this.=" \"$1.mov\"",$oac='pcm'  if(/^(.*[^_])\.mov$/);
 $this.=" \"$1.avi\""             if(/^(.*[^_])\.avi$/);
 $that =" \"$1_.avi\""            if(/^(.*)(a|-1)\.avi$/);
}

qx{mencoder -oac $oac -ovc $ovc -idx $this -o $that 1>&2} if($this && $that);
