for a in *.wav; do rasterisk -x "file convert /var/lib/asterisk/sounds/custom/$a /var/lib/asterisk/sounds/custom/echo $a|sed "s/.wav/.g729/""; done; If you get error unable to open input file, that means the input file is not in correct wav format, try this

sox foo-in.wav -r 8000 -c 1 -s -w foo-out.wav resample -ql