#!/bin/sh

if [ -z "$1" ]; then
 echo "Usage: ./convert_dir.sh <path_to_sample_directory>"
 exit
fi

pushd . && cd "$1" && mkdir -p 48k && cd 48k && find ../ -name \*.wav -print0 | xargs -0 printf "%s\n" >srclist.txt && rm -f filelist.txt && while read d ; do sox "${d}" -r 48000 -b 16 -c 1 "`basename "$d"`"; echo "`basename "$d"`" >>filelist.txt ; done <srclist.txt && cd .. && ls -1 48k/*.wav && popd

