#!/usr/bin/perl my @startlist = (); my @endlist = (); my $script = shift; my $outputfilename = shift; my $lastframe = shift; push @endlist, 0; foreach $cutpoint (@ARGV) { if ($cutpoint =~ m/(\d*)-(\d*)/) { my $start = $1; my $end = $2; if ($start eq "" and $end ne "") { # case where start is the very beginning $start = 0; } elsif ($start ne "" and $end eq "") { if ($start >= $lastframe) { next; } # case where end is the very end $end = $lastframe; } elsif ($start eq "" and $end eq "") { next; } # We have valid start and end frames now. We add them # to the array push @startlist, $start; push @endlist, $end; } } # now that we have the start and end lists, we need to generate the script push @startlist, $lastframe; if (scalar (@startlist) != scalar (@endlist)) { die "Invalid cutlist. The start and end lists don't match up.\n"; } open (SCRIPT, ">$script") or die "Unable to write to script file $script\n"; print SCRIPT "Load ( \"$outputfilename\" );\n"; for (my $index = scalar (@startlist) - 1; $index >= 0; --$index) { my $currentstart = $endlist[$index] + 1; my $currentend = $startlist[$index] - 1; if ($currentstart <= 1) { $currentstart = 2; } if ($currentend >= $lastframe - 1) { $currentend = $lastframe - 2; } if ($currentstart < $currentend) { print SCRIPT "RemoveFrames ($currentstart, $currentend);\n"; } } close SCRIPT;