Skip to content

Instantly share code, notes, and snippets.

@hjue
Last active November 13, 2019 21:57
Show Gist options
  • Save hjue/0e3098712b8552a8d76223e883818392 to your computer and use it in GitHub Desktop.
Save hjue/0e3098712b8552a8d76223e883818392 to your computer and use it in GitHub Desktop.
convert m4a to mp3
author=""
title=""
album=""
output="mp3"
for i in `find . -maxdepth 1 -type d 2>/dev/null`
do
if [ "$i" = "." ]; then
continue
fi
album=${i/.\//}
echo $album
for filename in $album/*.m4a ;
do
# echo $filename
if [ -f "$filename" ] ; then
if [ ! -d "$output/$album" ] ; then
mkdir "$output/$album"
fi
basename=`basename "$filename"`
title=`echo ${basename%.*}`
file="${title}.mp3"
outputfile="$output/$album/$file"
# echo $outputfile
# echo $filename
ffmpeg -y -i "$filename" -metadata title="$title" -metadata artist="$author" -metadata album="$album" -codec:a libmp3lame -ab 64k "${outputfile// /_}";
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment