#!/bin/bash

declare -r EXIT_FAILURE=1
declare -r EXIT_SUCCESS=0

declare -r XSTAR=xstar
declare -r SEGY=segy

if [ ! -d ${XSTAR} ]; then
    echo "ERROR: ${XSTAR} is not a directory!!!"
    exit ${EXIT_FAILURE}
fi

if [ ! -d ${SEGY} ]; then mkdir ${SEGY}; fi

for infile in xstar/*.sgy; do
    base=${infile##*/}
    base=${base%%.sgy}
    num=${base##xstar_lajolla}
    num=`printf "%03d" $num`
    base=lj${num}
    outfile=${SEGY}/${base}.${SEGY}
    #echo $num $base  

    echo "./convxstar.bash $infile $outfile"

done
