#!/bin/sh
#
# ========================================================================
#
# *
# * This file is part of MARS, the MAGIC Analysis and Reconstruction
# * Software. It is distributed to you in the hope that it can be a useful
# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
# * It is distributed WITHOUT ANY WARRANTY.
# *
# * Permission to use, copy, modify and distribute this software and its
# * documentation for any purpose is hereby granted without fee,
# * provided that the above copyright notice appear in all copies and
# * that both that copyright notice and this permission notice appear
# * in supporting documentation. It is provided "as is" without express
# * or implied warranty.
# *
#
#
#   Author(s): Martin Merck  05/2004 <mailto:merck@astro.uni-wuerzburg.de>
#
#   Copyright: MAGIC Software Development, 2000-2004
#
#
# ========================================================================

#/////////////////////////////////////////////////////////////////////////////
#
# mklinksyy
#
# This scripts creates in the local directors (directory where it is executed)
# a series of subdirectories for each date in which links to the rawdata are created.
# Normaly this script is used in a directory called rawdata2 to create links to
# the ying-yang corrected rawdata files.
# Already existing links are overwritten. Normally first the script mklinks should 
# be executed and then this script to overwrite the links for the yy corected rawdata
# files.
#
IN_DIR=/mcdata/yin_yang/Period015/rawdata
DATES=`ls -d -1 $IN_DIR/20* | cut -d/ -f6 '-'`
for DATE in $DATES
do
  OUTDIR=./$DATE
  if [ ! -d $OUTDIR ]
  then
    echo $DATE
    mkdir $OUTDIR
  fi

  cd $DATE
  RAWFILES=`ls -1 $IN_DIR/$DATE/*.raw`
  for i in $RAWFILES
  do
    ln -f -s $i `echo $i | cut -d/ -f7`
  done
  cd ..
done
