#!/bin/csh -f

foreach FILE (*.DAT)

   set DATA     = $FILE:r
   echo "Now working on: "$DATA
   set LABEL    = $DATA.LBL
   set NEWLBL   = $DATA.lbl
   set START    = `grep START_TIME $LABEL | sed s/1978/1987/g`
   set STOP     = `grep STOP_TIME $LABEL | sed s/1978/1987/g`
   set REC      = `grep FILE_RECORDS $LABEL`

   set F        = $START[3]
   set L        = $STOP[3]
   set R        = $REC[3]

   cp /pds/archive1/VOLUME/PV10_0002/DATA/THRM.DES $DATA.DES
   cp /pds/archive1/VOLUME/PV10_0002/DATA/DATA.ABS $DATA.ABS
   cp /pds/archive1/VOLUME/PV10_0002/DATA/DATA.HED $DATA.HED

   cat /pds/archive1/VOLUME/PV10_0002/DATA/LABEL_THRM.LBL | sed s/_rec/$R/g | sed s/_start/$F/g | sed s/_stop/$L/g | sed s/_file/$DATA/g > $NEWLBL
   /bin/mv $NEWLBL $LABEL

   mp bp=/pds/archive1/VOLUME/PV10_0002/DATA/thrm.bp INF=$DATA OUT=$DATA
   unix2dos $DATA.TAB
   /bin/rm *DES *HED *ABS *FMT INFO* $FILE
end

exit (0)

