Created
July 28, 2013 08:29
-
-
Save kitchen/6097944 to your computer and use it in GitHub Desktop.
flac to alac conversion using avconv
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 | |
downloaddir=$1 | |
if [[ -z "$downloaddir" ]]; then | |
echo "fatal, no arguments given" | |
exit 99 | |
fi | |
find "$downloaddir" -iname '*.flac' | while read flac; do | |
echo "found $flac" | |
dirname=`dirname "$flac"` | |
basename=`echo -n "$flac" | sed 's/\.flac$//i'` | |
basename=`basename "${basename}"` | |
fname="${dirname}/${basename}" | |
if ! [[ -f "${fname}.m4a" ]]; then | |
echo "alac "${fname}.m4a" doesn't exist, creating" | |
avconv -i "$flac" -acodec alac -- "${fname}.part.m4a" | |
if [[ "$?" -eq "0" ]]; then | |
mv -- "${fname}.part.m4a" "${fname}.m4a" | |
echo "success!" | |
else | |
echo "eek, something went awry: $?" | |
fi | |
else | |
echo "file was already converted, skipping" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment