#!/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
#
#
# ========================================================================

#/////////////////////////////////////////////////////////////////////////////
#
# mklinks
#
# 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 rawdata files.
# With a second script calle mklinksyy links to the ying-yang corrected files are
# created and the corresponing links overwritten. In this way the subdirectory
# rawdata2 will contain the correct links to the yy-files where necesary and the
# original rawdata files, when no yy correction was necessary.
#
DATES=`ls -d -1 ../rawdata/20* | cut -d/ -f3 '-'`
for DATE in $DATES
do
  OUTDIR=./$DATE
  if [ ! -d $OUTDIR ]
  then
    echo $DATE
    mkdir $OUTDIR
  fi

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