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!
Warning: Declaration of Social_Walker_Comment::start_lvl(&$output, $depth, $args) should be compatible with Walker_Comment::start_lvl(&$output, $depth = 0, $args = Array) in /Users/wade/Sites/hm2k.org/wp-content/plugins/social/lib/social/walker/comment.php on line 18
Warning: Declaration of Social_Walker_Comment::end_lvl(&$output, $depth, $args) should be compatible with Walker_Comment::end_lvl(&$output, $depth = 0, $args = Array) in /Users/wade/Sites/hm2k.org/wp-content/plugins/social/lib/social/walker/comment.php on line 42
Doing this costs A LOT of sound quality.
Awsome! Thanks!
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?
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”
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?
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.
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
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.
Fantastic work my friend! This is so easy and works so well!
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.
[…] Batch WMA Lossless > MP3 transcode ? If you don't mind getting your hands dirty: http://www.hm2k.com/posts/how-to-bul…ert-wma-to-mp3 Originally Posted by Agent …every time Creative bring out a new card range their […]
The script works great. For non scripters.. the character errors are caused by double quotes getting copied as some other wierd character.. Replace those with the normal double quote and the script works great. Thanks a Lot
Michael
Thanks, it worked beautifully. Working with win 7 and had to get “send to” by Start->Run (Type in “shell:sendto” without quotes)
Apart from that, I smply followed your steps.
Thanks alot,
JW