#!/usr/bin/perl -w use Gimp; Gimp::init; use File::Basename; $progname = basename($0); ### Process arguments use Getopt::Long; Getopt::Long::Configure ("bundling"); GetOptions("pattern-in|i=s" => \$pattern_in, "start-in|I=i" => \$start_in, "pattern-out|o=s" => \$pattern_out, "start-out|O=i" => \$start_out, "num-frames|n=i" => \$num_frames, "help|h" => \$help); arg_error("") if $help; arg_error("-i or --pattern-in required!") if !$pattern_in; arg_error("-I or --start-in required!") if !$start_in; arg_error("-o or --pattern-out required!") if !$pattern_out; arg_error("-O or --start-out required!") if !$start_out; arg_error("-n or --num-frames required!") if !$num_frames; ### Loop through the frames applying the filter for ($i = 0; $i < $num_frames; ++$i) { $file_in = sprintf $pattern_in, $start_in + $i; $file_out = sprintf $pattern_out, $start_out + $i; system("cp $file_in $file_out"); print "$progname: $file_in -> $file_out\n"; } sub arg_error { ### Display errors in arguments and usage my ($message) = @_; if ($message ne "") { print "$progname: Los parametros elegidos son incorrectos!\n\n"; print "*** $message ***\n"; } print <<"EOUSAGE"; Description: $progname copies the input frames to the output frames. Usage: $progname [options] Options: -i or --pattern-in (required) The printf formatted pattern for the input frames. -I or --start-in (required) The starting frame number for the input frames. -o or --pattern-out (required) The printf formatted pattern for the output frames. -O or --start-out (required) The starting frame number for the output frames A. -n or --num-frames (required) The number of frames to copy. -h or --help (optional) Print usage message and exit Example: $progname -i in%d.jpg -I 31 -o out%06d.png -O 47 -n 500 -- copies frames in31.tga ... in530.tga to frames out000047.tga ... out000546.tga. EOUSAGE exit 1; }