#!/bin/csh -f
#
#foreach i (`ls rawdata/*JC32*`)

# overhaul on jr302 may 2014, to fit with new python codas
# may need modification on cook/discovery to handle os75 and os150
cd /local/users/pstar/cruise/data/vmadcp/

echo "synchronising raw data"
rsync -av ../jcrfs/current/adcp/ jr17001_os75/vmdas_data/
# jcrfs is link to raw data on jrlb

echo "making links to individual sequence directories"
cd jr17001_os75/vmdas_data
foreach i (`ls *.*`) # list all *.* to avoid collecting N1R directory
set num = `echo $i | awk -F'.' '{print substr($1,length($1)-9,3)}'`

set linkdir = rawdata{$num}

if (! -e $linkdir) then
  echo making $linkdir
  mkdir $linkdir
endif

set rfile = $i
set lfile = $i
cd $linkdir
if (! -e $lfile) then
  echo linking ${lfile} to ${rfile}
  ln -s ../${rfile} ${lfile}
endif
cd ..

end