A bash one-liner to batch convert the sampling rate of WAV files using the SoX tool. The example will resample *.wav files in the current directory to 8000Hz and place the output in an existing subdirectory called 8000Hz.
The one-liner below is overkill for this task, but the extra arguments provide a starting point for modification for related tasks. The use of find
/xargs
should help the one-liner deal with very large numbers of audio files and filenames that contain whitespace.
Code
find . -maxdepth 1 -name '*.wav' -type f -print0 | xargs -0 -t -r -I {} sox {} -r 8000 8000Hz/{}