#!/bin/csh -f
#
#Script by BAK on cruise jc032 to create symbolic links.
#Modified by CPA on di346 for nutrient data
#Set to import all files from Drobo each time script is run to ensure
#most up to date files are kept on nosea1  
#The assumption is that the raw files are named
#in a way that identifies the instrument, eg
# ctd_jc032_001_ctm.cnv
#
#
# The initial foreach command will need to be modified for each cruise.


# modded bak jr302 8 jun 2014 to use rsync
cd
cd cruise/data
cd ctd
cd BOTTLE_NUT 

rsync -av jcrfs_nut/J*csv .


foreach i (`ls JR302nut???.csv`)
#echo $i
set num = `echo $i | awk '{print substr($1,9,3)}'`
#echo $num
#set cruise = `echo $i | awk '{print substr($1,9,5)}'`
set cruise = 'jr302'
#echo $cruise

set linkfile = nut_${cruise}_${num}.csv
#echo $linkfile

if (! -e $linkfile) then
  echo Making link $linkfile for raw file $i
  ln -s $i $linkfile
endif
end