#!/bin/csh
#
# IPAC/ISOPHOT -- unpackiso 


if ($#argv != 0) goto usage

echo " "
echo "Hello, you are using the 'unpackiso' script from IPAC"

echo " "
echo "... doing unpacking:"
foreach f (`find . -type f -name \*.tar.gz -print`)
   set filename = `basename $f`
   echo $filename
   gunzip $filename
   set filename = `basename $f .gz`
   tar -xf $filename
end

echo " "
echo "... now renaming files to the PIA convention:"
foreach f (`find . -type f -name \*.fits -print`)
   set file1 = `basename $f`
   set file2 = `basename $f .fits`
   set file2 = `echo $file2 | tr '[a-z]' '[A-Z]'`.FITS
   mv $file1 $file2
   echo "mv $file1 to $file2"
end

echo "... done"
echo " "
exit 0

usage:
echo "Usage: First, go to the directory where your ISO data are located,"
echo "       then simply type 'unpackiso' at the prompt:"
exit 1