#!/bin/bash
#Author Martin Prudek

if [ $# -ne 1 ]; then
	echo "Data dir not specified. Gutting.";
	exit 1;
fi

mkdir -p "$1"/__abstimes;
for file in `ls "$1"/*.rdat`; do
	filename=`echo "${file}" | sed 's:.*/::'`;
	. ./parse_name.sh "${filename}";
	if [ ! -e "$1/__abstimes/${filename}.at" ]; then
		if [ "${nm[t]}" = "lat" ]; then
			cat ${file} | sed '/^#/ d' |\
				./comp_lat_abstimes \
				> "$1/__abstimes/${filename}.at";
		fi
		if [ "${nm[t]}" = "can" ]; then
			cat ${file} | sed '/^#/ d' | cut -c 3- |\
				 cut -c -17 |\
				./comp_can_abstimes \
				 > "$1/__abstimes/${filename}.at";
		fi
	fi
done
