#! /bin/csh -f

set fl_size = `wc -l < GOODS_HST.phot`
set cnt_i = 0
set HPS_num = `cat GOODS_HST.phot | awk '{print $1}' | sed 's/HPS//'`
while ($cnt_i < $fl_size)
   @ cnt_i = $cnt_i + 1
   set old_num = `cat ../pap_cat3.out | awk 'NR==var1{print $2}' var1=$HPS_num[$cnt_i]`
      if ($old_num < 10) then
         set cnt_p = "00$old_num"
      else if ($old_num < 100) then
         set cnt_p = "0$old_num"
      else
         set cnt_p = "$old_num"
      endif
   mv imaging/HST${cnt_p}.ps imaging/HPS${HPS_num[$cnt_i]}_HST.ps
end
exit(0)
