#!/bin/sh
# Version: 0.2.0
# Author: Dimitrios Dimitrakos mail@dimitrios.de
# $Id: marks2times.sh,v 1.3 2004/10/19 13:55:36 dimi Exp $
#set -x

DIR=$1
FILE=/tmp/chapters.$$

if [ -d $DIR ]
then
    #printf "%s," 0 > $FILE
    > $FILE
    marklines=`cat $DIR/marks.vdr|wc -l`
    let marklines=marklines-1
    
    for t in `cat $DIR/marks.vdr|head -n $marklines|cut -f1 -d'.'`
    do
       printf "%s," $t >> $FILE
    done
    for t in `cat $DIR/marks.vdr|tail -n 1|cut -f1 -d'.'`
    do
       printf "%s\n" $t >> $FILE
    done
    Chapters=`cat $FILE`
    TimeforFrames=""
    BlankforFrames=`echo $Chapters|sed 's/,/ /g'`
    for i in $BlankforFrames
    do
       [ "${TimeforFrames}" = "" ] && \
            TimeforFrames=${i}-${i}.0 || \
            TimeforFrames=${TimeforFrames},${i}-${i}.0
    done
    [ ! -z "$TimeforFrames" ] && echo $TimeforFrames
    [ -f $FILE ] && rm $FILE
fi
