How to bulk convert WMA to MP3

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>
Run ffmpeg
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
objINext=Right(objIN,3)
If objINext = “wma” Then
objINCount=len(objIN)
objINCount=objINCount-3
objOUT=Left(objIN,objINCount)&”mp3″
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
End If
i = i + 1
Next
WScript.Echo “Done!”

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!

Related posts:

  1. My AVI files crash explorer.exe Often when I am browsing files using explorer I will...
  2. How to Print to a Text File Device Manager does not have a Save command available for...

10 Comments »

  1. Justin said,

    July 14, 2008 @ 6:27 am

    Doing this costs A LOT of sound quality.

  2. Anonymous said,

    August 28, 2008 @ 2:11 am

    Awsome! Thanks!

  3. Scott said,

    October 3, 2008 @ 8:46 pm

    It keeps giving me a “character” error, either line one or line 5 depending on which text type I save the script as? any ideas?

  4. Scott said,

    October 3, 2008 @ 9:04 pm

    well I got it to run the script. the issue is that when you copy from “firefox” the quotation marks become smart quotes and the script can’t read them. I finally figured out that you had to open that up in wordpad change the quotes by retyping them, also the longest line of code needs to all be on one line, and it needs to be saved in “unicode text”

  5. Scott said,

    October 3, 2008 @ 9:15 pm

    It runs the script, but nothing happens? what’s wrong? it’s supposed to convert the existing wma into an mp3 right there in the folder right? any of the test wma’s I’ve used the script on, opens the “lame” looking dialog box for a split second, then says done, but nothing changes to the file, or if it does it doesn’t tell me where the new one is located?

  6. hm2k said,

    October 6, 2008 @ 11:25 am

    With regards to the quotes, yes, unfortunately wordpress encodes them stupidly, and i’ve not yet got around to figuring out how to disable that. You just need to manually put real quotes in.

    As for the rest, you must be doing something wrong.

    Use WScript.Echo objExec to return the string, then type that into a cmd, see if it works from there.

    It should display an error, and you can take it from there.

  7. anon said,

    December 21, 2008 @ 9:28 am

    vbs replace function http://www.w3schools.com/Vbscript/func_replace.asp

    but its more sensible to do what you are doing in this instance any way

  8. 3l1t3 said,

    May 12, 2009 @ 1:20 am

    Thank you very much worked great , exactly what I needed I could right click multiple selected files too, which converted all the files into the same folder , Maybe you can help me with my other task of printing a full list of music songs and artists , I’ve googled but haven’t really found exactly what i’m looking for. not too handy with my own scripts but i figure there has to be a way Thanks again.

  9. Mat Dodgson said,

    October 11, 2009 @ 1:14 am

    Fantastic work my friend! This is so easy and works so well!

  10. Rob said,

    February 16, 2010 @ 12:32 am

    This works great!

    I use ffmpeg to convert video for my phone, and I use shortcuts in SendTo for Notepad, but never thought about putting a vbs script in there.

    Thanks very much for this tip! Now I can listen to wma files on my phone.

RSS feed for comments on this post · TrackBack URL

Leave a Comment