#!/bin/bash
# By Marko Haapala
# converts wma to mp3 recursively. does not delete any static files, so
# cleanup and renaming is needed afterwards.
#
# Modified by V10lator
# to delete the wma files and to use /tmp for temporary files
#
# requirements:
# lame - http://lame.sourceforge.net/download.php
# mplayer - apt-get install mplayer or http://www.mplayerhq.hu/design7/dload.html
current_directory=$(pwd)
tmp_file=$(mktemp -t -u --suffix=.wav)
wma_files=$(find "${current_directory}" -type f -iname "*.wma")
# Need to change IFS or files with filenames containing spaces will not
# be handled correctly by for loop
IFS=$'\n'
for wma_file in ${wma_files}; do
mplayer -vo null -vc dummy -af resample=44100 \
-ao pcm -ao pcm:waveheader -ao pcm:file="${tmp_file}" \
"${wma_file}" && lame -m s "${tmp_file}" \
-o "${wma_file}".mp3 && rm "${wma_file}"
rm "${tmp_file}"
done