32

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.

1
  • As of note, if any WMA files have DRM on them, no Linux application will be able to decrypt them.
    – Broam
    Aug 1, 2011 at 15:01

11 Answers 11

45

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 :)

4
  • 2
    This is certainly simple point and click. +1 from me :-)
    – Rory Alsop
    Aug 1, 2011 at 15:04
  • 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. Aug 1, 2011 at 15:19
  • 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 :)
    – Achu
    Aug 2, 2011 at 13:26
  • 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. Feb 23, 2021 at 16:14
19

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
7
  • 1
    Thanks, but I need one that goes through directories recursively, since they're spread out through many subdirectories of ~/Music. Aug 1, 2011 at 15:00
  • 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
    Aug 1, 2011 at 15:04
  • This answer isn't working for me in 2013. However this answer works: askubuntu.com/a/55469/36661
    – MountainX
    Aug 4, 2013 at 2:21
  • 1
    The quick-and-dirty version still works in 2016 (on 14.04) if you replace -ao pcm -waveheader with -ao pcm:waveheader.
    – m00am
    Dec 24, 2016 at 13:14
  • 1
    Good scripted solution. Works with no modification in Sep. 2019 on xubuntu 19.04.
    – Balu
    Sep 15, 2019 at 14:02
17

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.

2
  • 3
    This still works well in 2013
    – MountainX
    Aug 4, 2013 at 2:21
  • @David Futhcher, mentioning reference is nice habit :-), thank you! Jul 10, 2018 at 14:39
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

3

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
1
  • 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. Jul 10, 2018 at 14:45
1

For those who are looking for a GUI version that is able to select certain filetypes: the KDE tool soundKonverter https://github.com/HessiJames/soundkonverter asks which filetypes should be added to the conversation queue.

Best solution for my huge Audiobook collection containing mp3/ogg/wma files.

1

Here is my edition of Marko Haapala script, using ffmpeg:

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
# Also, it must be run as root to correctly handle spaces on Ubuntu 16
IFS=$'\n'
for wma_file in ${wma_files}; do
 ffmpeg -i "${wma_file}" -q:a 0 "${wma_file}".mp3
 #uncomment rm below to delete original wma's
 #rm "${wma_file}"
done

I prefer ffmpeg, because it doesn't change sample rate and it doesn't need intermediate temp file

0

Soundcoverter shows an error something about Windows Media module and Python 2.7

Avconv worked fine: avconv -i ./song.wma song.mp3

0

You can also use my app... dmMediaConverter in Bulk mode. For help see this video...instead of video files, drag and drop the wma ones. https://www.youtube.com/watch?v=rZR40mdFRoQ&index=1&list=PLwURYFQvHBAtG8wqzyVgOQ1WtEYSkiscO

0

You can just use ffmpeg for this purpose:

$ shopt -s globstar # enable ** globing support
$ for wma_file in **/*.wma; do
    ffmpeg -i "$wma_file" "${wma_file%%.wma}.mp3"
  done
0

I use WinFF, which is basically a GUI for ffmpeg

sudo apt install winff

It works for either audio and video.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .