Convert library of WMA tracks to MP3's?
Solution 1
MPlayer is likely to be installed already. Also make sure you have lame:
sudo apt-get install mplayer lame
Then there are two ways to do it, an easy to read version, and a short and dirty script to do it:
All wma's should be in your current directory. Create a file called wmamp3 in your home directory (~/) containing:
#!/bin/bash
current_directory=$( pwd )
#remove spaces
for i in *.wma; do mv "$i" `echo $i | tr ' ' '_'`; done
#remove uppercase
for i in *.[Ww][Mm][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
#Rip with Mplayer / encode with LAME
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm -ao pcm:waveheader $i && lame -m s audiodump.wav -o $i; done
#convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.mp3"; done
#cleanup
rm audiodump.wav
chmod +x ~/wmamp3
to make it executable
sudo cp ~/wmamp3 /usr/bin
to pop it somewhere useful on your path
Type "wmamp3" to run your conversion.
The short and dirty version (does exactly the same as above):
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm -ao pcm:waveheader "$i" && lame -m j -h --vbr-new -b 160 audiodump.wav -o "`basename "$i" .wma`.mp3"; done; rm -f audiodump.wav
Solution 2
Install Soundconverter
and run Soundconverter
from launcher or terminal
The default conversion is .ogg
change this to mp3
going to edit-> preferences
under type of results. Format
to MP3 as follow:
Click on add folder and then select your music folder. You may select the output folder on the above preference configuration before you clicking on convert.
Hope this will be done by two clicks :)
Solution 3
Mplayer and lame must be installed first:
sudo apt-get install mplayer lame
Then create the script (reference page ) and execute it:
#!/bin/bash
# By Marko Haapala
# converts wma to mp3 recursively. does not delete any static files, so
# cleanup and renaming is needed afterwards.
#
# requirements:
# lame - http://lame.sourceforge.net/download.php
# mplayer - apt-get install mplayer or http://www.mplayerhq.hu/design7/dload.html
current_directory=$(pwd)
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 "${wma_file}" && lame -m s \
audiodump.wav -o "${wma_file}".mp3
rm audiodump.wav
done
Looks like it does exactly what you want. Bear in mind you may want to fiddle with the lame flags to ensure you get the desired quality level.
Solution 4
Install the Perl Audio Converter (pacpl): sudo apt-get install pacpl
This command will convert all wma files in a given directory to mp3 files (leaving the originals intact):
pacpl -r -to mp3 -only wma <directory name>
If you are feeling risky you can add the --delete
option to also remove the originals:
pacpl -r --delete -to mp3 -only wma <directory name>
I
Solution 5
I know this is a bit old but I modified the script shown by David Futcher. The changes are:
Use
/tmp
instead of the current folder for the temporary wav file (this gave a large speedup when I used this to convert files on a USB stick).Remove the wma files after they have been (hopefully successfully) converted.
Here it is:
#!/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
Related videos on Youtube
Mike Crittenden
Updated on September 18, 2022Comments
-
Mike Crittenden over 1 year
I know there are options such as Sound Converter for doing them one track or directory at a time, but are there any tools that will recursively crawl through a directory's subdirectories and convert all WMA's to MP3's?
I basically would like to let it loose on my ~/Music and let it do its thing without me manually having to give it one subdirectory at a time.
-
Broam almost 13 yearsAs of note, if any WMA files have DRM on them, no Linux application will be able to decrypt them.
-
-
Mike Crittenden almost 13 yearsThanks, but I need one that goes through directories recursively, since they're spread out through many subdirectories of ~/Music.
-
Rory Alsop almost 13 yearsYou can easily expand the script to do a recursive file hunt - I'd probably redo that first script using find, piping the output to mplayer.
-
Rory Alsop almost 13 yearsThis is certainly simple point and click. +1 from me :-)
-
Mike Crittenden almost 13 yearsThe problem with this solution is that SoundConverter performs extremely slowly or just freezes completely when more than a couple hundred songs are added at once, and my library has around 5k.
-
Achu over 12 years5k? wooo that is a lot ;) anyway it depends on your computer performance. may be you have to separate those files. personal i converted a couple of hundred songs without any freezes :)
-
MountainX over 10 yearsThis still works well in 2013
-
MountainX over 10 yearsThis answer isn't working for me in 2013. However this answer works: askubuntu.com/a/55469/36661
-
m00am over 7 yearsThe quick-and-dirty version still works in 2016 (on 14.04) if you replace
-ao pcm -waveheader
with-ao pcm:waveheader
. -
diachedelic over 6 yearsWorked for me on MacOS Sierra with no modifications. I had to do a
brew install mplayer
first. -
AjayKumarBasuthkar almost 6 years@David Futhcher, mentioning reference is nice habit :-), thank you!
-
AjayKumarBasuthkar almost 6 yearslast two lines can be merged :-)
-o "${wma_file}".mp3 && rm "${wma_file}" "${tmp_file}"
this would sligtly increase the speed of processing as another exec for rm is absent. -
php_nub_qq over 5 yearsWell in almost 2019 the dirty version seems to work pretty fine on ubuntu 18
-
Balu over 4 yearsGood scripted solution. Works with no modification in Sep. 2019 on xubuntu 19.04.
-
Warren Hill about 3 years5k+ files is small if you are a music fan. This is working for me but I am limiting this to a few 200 files, or less, per batch. original library sorted by Artist/Library. I have nearly 10k files to convert so will probably take a few days to complete.