#!/bin/bash
#
# dist.sh - script to look for rocking curve files in "latest" directory
#           and create parallel directories named according to the scan
#           name convention, copying the associated scan files to their
#           corresponding directory using hard links.
#
# author: richard.t.jones at uconn.edu
# version: february 24, 2015

for study in `ls latest | grep study | grep -v tiff`; do
    if [[ ! -d $study ]]; then
        mkdir $study
    fi
    ln latest/$study $study/
    for tiff in `ls latest | grep ${study}_scan'.*'.tiff`; do
        cp -l latest/$tiff $study/$tiff
    done
done
