Convert library of WMA tracks to MP3's?
Emily Wong
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.
111 Answers
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 :)
4MPlayer is likely to be installed already. Also make sure you have lame:
sudo apt-get install mplayer lameThen 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.wavchmod +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 Mplayer and lame must be installed first:
sudo apt-get install mplayer lameThen 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 -
# mplayer - apt-get install mplayer or
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
doneLooks 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.
2Install 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
I know this is a bit old but I modified the script shown by David Futcher. The changes are:
Use
/tmpinstead 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 -
# mplayer - apt-get install mplayer or
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 For those who are looking for a GUI version that is able to select certain filetypes: the KDE tool soundKonverter asks which filetypes should be added to the conversation queue.
Best solution for my huge Audiobook collection containing mp3/ogg/wma files.
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}"
doneI prefer ffmpeg, because it doesn't change sample rate and it doesn't need intermediate temp file
Soundcoverter shows an error something about Windows Media module and Python 2.7
Avconv worked fine: avconv -i ./song.wma song.mp3
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.
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 I use WinFF, which is basically a GUI for ffmpeg
sudo apt install winffIt works for either audio and video.