dotfiles/bin/wav2alaw

27 lines
516 B
Plaintext
Raw Permalink Normal View History

#!/bin/bash
# Converts all wav-files in a directory to alaw.
if [[ -z "$1" ]]; then
DIR='.'
else
if [ ! -d "$1" ]; then
echo "Directory does not exist!"
exit
else
DIR=$1
fi
fi
cd $DIR
for f in `ls -1 *.wav | sed 's/\.[^.]*$//' | sort -n`; do
echo "Converting $f.wav to $f.alaw..."
`sox $f.wav --channels 1 --encoding a-law --rate 8000 --type raw $f.alaw.wav`
if [ $? -eq 0 ]; then
`mv $f.alaw.wav $f.alaw`
`rm $f.wav`
fi
done
echo "Done."