How to bulk convert WMA to MP3May 12, 2008
So you just downloaded an entire album, and it’s in .wma (windows media audio) format, and you, of course, like any normal person want it in the .mp3 format.
What do you do?
There’s plenty of software solutions out there…
- SUPER – Free, converts anything, a bit dodgy.
- Various FFmpeg based projects – Free
- dBpoweramp Music Converter – 30 days free trial
- Daniusoft MP3 WAV Converter – Free
- Audio MP3 WAV WMA OGG Converter – Shareware
- All To MP3 Converter – Shareware
- WinFF – Free, Open source.
… but none of these really did what I wanted.
I decided to make my own tool.
My premiss was to make a bulk wma to mp3 converter for windows, that appears on context menus.
I figured that I could probably get away with using the “Send To” context menus instead.
I also figured that I could use the windows release of ffmpeg (windows binary contained within the 7zip files which open with WinRAR) at the core to do the actual conversion.
My advice would be to extract ffmpeg.exe to your “system32″ directory so we can call it from anywhere.
I figured out by using WinFF, that the command is as follows:
ffmpeg -i “in.wma” -acodec libmp3lame -ab 160k -ac 2 -ar 44100 “out.mp3″
Note: WinFF uses “mp3″ instead of “libmp3lame” due to the way it’s compiled
The next step was to figure out how to pass the arguments to ffmpeg.exe so it knew the input and output file.
In the end I settled on VBscript, thanks to a very handy documentation entitled “Introduction to VBScript“.
What I needed to do in psudo terms is as follows:
Get <arguments> as <input>
For Each <input> as <item>
Check <item> is a “.wma” file
Replace .wma with .mp3 on end of <item>
Tell us when it’s all done
In VBS, you are unable to “replace”, so instead I simply trimmed the last 3 chrs (wma) and added “mp3″.
Also to insert quotes (since there’s no escaping) you simply use chr(34).
Another article worth mentioning is entitled “Running Programs From WSH Scripts“. It helps explain the difference between Run and Exec, and the ways in which to use them.
Here’s the script I ended up with:
Set objS = WScript.Arguments
i = 0
For Each objIN in objS
If objINext = “wma” Then
objExec=”ffmpeg.exe -i “&chr(34)&objIN&chr(34)&” -acodec libmp3lame -ab 160k -ac 2 -ar 44100 “&chr(34)&objOUT&chr(34)
Set objShell = CreateObject(“WScript.Shell”)
objShell.Run(objExec), 1, true
i = i + 1
Go to Start -> Run, enter: “sendto”, click OK or press Enter.
Create a New Text Document in there, open it, and paste in the above script, then rename it to “wma-to-mp3.vbs”.
That’s it, all done!
Now when you right click on a WMA file, and go to the “Send To” menu, you will see an option called “wma-to-mp3.vbs”, click on that, and the process will begin.
Note: I am aware that there are limits to this script, but it does the job. Let me know of any improvements you make, and enjoy!