Convert library of WMA tracks to MP3's?

40,017

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 Install soundconverter

and run Soundconverter from launcher or terminal

enter image description here

The default conversion is .ogg change this to mp3 going to edit-> preferences under type of results. Format to MP3 as follow:

enter image description here

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
Share:
40,017

Related videos on Youtube

Mike Crittenden
Author by

Mike Crittenden

Updated on September 18, 2022

Comments

  • Mike Crittenden
    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
      Broam almost 13 years
      As of note, if any WMA files have DRM on them, no Linux application will be able to decrypt them.
  • Mike Crittenden
    Mike Crittenden almost 13 years
    Thanks, but I need one that goes through directories recursively, since they're spread out through many subdirectories of ~/Music.
  • Rory Alsop
    Rory Alsop almost 13 years
    You 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
    Rory Alsop almost 13 years
    This is certainly simple point and click. +1 from me :-)
  • Mike Crittenden
    Mike Crittenden almost 13 years
    The 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
    Achu over 12 years
    5k? 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
    MountainX over 10 years
    This still works well in 2013
  • MountainX
    MountainX over 10 years
    This answer isn't working for me in 2013. However this answer works: askubuntu.com/a/55469/36661
  • m00am
    m00am over 7 years
    The quick-and-dirty version still works in 2016 (on 14.04) if you replace -ao pcm -waveheader with -ao pcm:waveheader.
  • diachedelic
    diachedelic over 6 years
    Worked for me on MacOS Sierra with no modifications. I had to do a brew install mplayer first.
  • AjayKumarBasuthkar
    AjayKumarBasuthkar almost 6 years
    @David Futhcher, mentioning reference is nice habit :-), thank you!
  • AjayKumarBasuthkar
    AjayKumarBasuthkar almost 6 years
    last 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
    php_nub_qq over 5 years
    Well in almost 2019 the dirty version seems to work pretty fine on ubuntu 18
  • Balu
    Balu over 4 years
    Good scripted solution. Works with no modification in Sep. 2019 on xubuntu 19.04.
  • Warren Hill
    Warren Hill about 3 years
    5k+ 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.