#!/bin/csh -f
# 02.09.92 reverse Alex Urrutia + Keven Fedirko v1.01
#
# This interactive script will change the numbering of a sequence of frames to
# the reverse order.  i.e., frames from 1 to 50 will be numbered from 50 to 1,
# so upon viewing will appear backwards.  Note:  This should NOT be used on
# field rendered images, for obvious technical reasons.  Because of the nature
# of this process, it is necessary to create a new filename for the output
# file.

if ($#argv < 2) then
	echo
	echo "Usage: reverse <input> <output> "
	echo
	exit -1
endif
@ max = 0
@ min = 999999
foreach i ( `\ls ./$1*.pic` )
	set nohead = $i:t
	set no_pic_ext = $nohead:r
	@ current_count = $no_pic_ext:e
	if ($max < $current_count) then
		@ max = $current_count
	endif
	if ($min > $current_count) then
		@ min = $current_count
	endif
end
foreach i ( `\ls ./$1*.pic` )
	set nohead = $i:t
	set no_pic_ext = $nohead:r
	set current_count = $no_pic_ext:e
	@ newcount = ($max - $current_count) + $min
	cp $i $2.$newcount.pic
end
