Last active
August 29, 2015 13:59
-
-
Save briansorahan/10669324 to your computer and use it in GitHub Desktop.
Convert sound files to wav with mpg123 and sndfile-convert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Convert all soundfiles of a particular type located in the | |
# current directory to wav. | |
# | |
function convertToWav { | |
local ext="$1"; shift | |
for f in *.${ext}; do | |
# mp3 can't be converted by sndfile-convert | |
# use mpg123 instead | |
if [[ -n $(echo "$f" | grep mp3) ]]; then | |
mpg123 -w "${f/%.mp3/.wav}" "$f" | |
else | |
sndfile-convert "$f" "${f/%.${ext}/.wav}" | |
fi | |
done | |
} | |
convertToWav mp3 | |
convertToWav flac | |
# add more extensions as appropriate | |
# see output of sndfile-convert for supported file types |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment