#!/usr/bin/perl # # usage: perl shiftsnap.pl shift snapfiles # # e.g. perl shiftsnap 103 snap.*.sgi changes all picture names # from snap.x.sgi to snap.x+103.sgi # # (Warning: will overwrite snap.x+103.sgi if it exists already!) # # Note that imagefiles have to be of the form snap.. # # Dinoj Surendran 12 Feb 03 dinoj@cs.uchicago.edu ($shift,@imagefiles) = @ARGV; if ($shift < 0) { for ($i = 0; $i < $#ARGV; $i++) { ($sn, $num, $ext) = split /\.+/ , $imagefiles[$i]; $a = $num+$shift; $nufile = $sn.".".$a.".".$ext; $cmd = "mv ". $imagefiles[$i]." $nufile"; print "$cmd\n"; system($cmd); } } elsif ($shift > 0) { for ($i = $#ARGV-1; $i >= 0 ; $i--) { ($sn, $num, $ext) = split /\.+/ , $imagefiles[$i]; $a = $num+$shift; $nufile = $sn.".".$a.".".$ext; $cmd = "mv ". $imagefiles[$i]." $nufile"; print "$cmd\n"; system($cmd); } }