A few months back, I was attempting to load my music collection on my iPhone for the first time and was encountering issues. My situation:
- I was running iTunes in a Virtual Machine to avoid all the crapware that iTunes installs.
- My music library was a combination (about half and half) of WMA and MP3 files.
- My music library was well organized in a folder hierarchy.
- The iTunes converter was giving me grief upon importing my music library. (I seem to recall that due to the use of virtual machine snapshots, iTunes kept getting confused and re-converting certain WMA files that had already been converted by it; furthermore, due to the virtualization, conversion of my music library was taking forever!)
“No problem,” I thought, “I’ll just find a tool to batch-convert my entire music library to MP3 format, which is compatible with iTunes.” My plan was to run this once on the host and then import the entire (converted) folder into iTunes on the VM.
My requirements were as follows:
- Tool shall recursively process the music library folder.
- Tool must allow specification of an output folder that is different from the source folder.
- Upon executing conversion, tool shall replicate the source folder hierarchy, recreating that folder hierarchy within the destination folder.
- Upon encountering a WMA file, tool shall auto-convert the file and place the resulting MP3 file in the same relative location in the destination folder hierarchy. (My various audio files frequently had the same filenames but were in different folders in the folder hierarchy, so putting everything in one single-level folder wouldn’t work.)
- Upon encountering a non-WMA file, tool shall support automatic duplication of the source file to the same relative location in the destination folder hierarchy. (This way, my MP3 files would simply be duplicated and not converted.)
After understanding what I wanted to do, I spent quite a while searching the Internet for a conversion tool that supported my (rather simplistic) requirements. I downloaded, installed, and tested (in a VM) quite a few tools, and none of them supported what I wanted. In many cases, the tools failed to support folder recursion, and for those tools that did, the tool either converted the files in place or dumped all of the files (from all the subfolders) into a single output folder without replicating the folder hierarchy.
At this point, I was pretty annoyed with the various converters available; whether “free” or “paid,” most were very poorly designed, unstable, and generally “overkill” for my problem. After over an hour of experimenting, I stumbled upon a blog post that discussed the use of vbscript + FFmpeg to do the conversion.
Using FFmpeg to do the conversion had occurred to me, but I lacked an easy way to run FFmpeg recursively and duplicate the source folder hierarchy. At this point; however, I was ready to script those aspects of the conversion myself. I liked the approach taken by the Phurix Labs script (in the above blog post) to make use of the “Send To” menu to allow for easy activation of the script. So, I retained that aspect but wrote the recursive code mostly from scratch…
A few hours later, and I had my script finished. Yes, vbscript is painful, but it has the advantage of working natively on practically any Windows system.
Download
Version: 0.85
Script Download Link
Features:
- Recursive traversal of the selected folders. Selection of more than one source folder/file is allowed.
- Supports two output options:
- In-place conversion. Places resulting MP3 files in the same location as the original WMA files.
- Selection of alternate output directory. Source folder tree is replicated to destination folder and resulting MP3 files are placed in the same relative location. User is also given the option to duplicate or ignore non-WMA files.
- Script complains if a particular FFmpeg conversion process appears to be taking too long.
Installation Instructions
- Download FFmpeg.
- Visit the FFmpeg site, scroll down to “Windows Binaries” and follow the instructions from there.
- Use 7-zip to extract the FFmpeg binaries to a folder such as C:\Program Files (x86)\FFmpeg\
- Add the directory containing FFmpeg to the system path. Google it if you don’t know how to do this.
- Download & install the script.
- Download the .vbs script file.
- Open the “send to” folder in Windows by either typing “shell:sendto” into an Explorer window’s address bar or using Start -> Run.
- Copy the .vbs script file into the “send to” folder.
Run the script by right-clicking on the source folder(s) and/or source files(s) and clicking Send To –> Convert WMA to MP3.
I really appreciate this script! Google Music doesn’t accept wma files, and I need my tunes somewhere safe! 🙂
Keep walking with Jesus. 🙂
give this a try. a culmination of script searching over the years…
change your file types in according spaces then it’s drag and drop.
@echo off
setlocal ENABLEDELAYEDEXPANSION
::parse multiple command lines (so multiple targets can be dragged and dropped at once)
:commandlineloop
if “%~1″==”” goto :continue
call :mainloop %1
shift
goto :commandlineloop
:continue
echo.
pause
goto :eof
::main loop we run for each command line arg of the script
:mainloop
set folderpath=
if “%~1″==”” (
echo Drag and drop files or folders onto this script.
goto :eof
)
set folderpath=%~1
echo “%1” | find /I “.mov” && (
goto :fileonly
)
echo “%1” | find /I “.m4v” && (
goto :fileonly
)
echo “%1” | find /I “.mp4” && (
goto :fileonly
)
echo “%1” | find /I “.wmv” && (
goto :fileonly
)
echo “%1” | find /I “.flv” && (
goto :fileonly
)
echo “%1” | find /I “.avi” && (
goto :fileonly
)
echo “%1” | find /I “.mpeg” && (
goto :fileonly
)
::folders
echo.
echo.
echo Processing folder %1
echo ________________________________________________________________________________
echo.
::we need to find the last folder level in the folderpath
set temp_string=%~1
set count=0
:loopcounter
for /F “tokens=1* delims=\” %%a in ( “%temp_string%” ) do (
set /A count+=1
set temp_string=%%b
goto loopcounter
)
for /F “tokens=%count% delims=\” %%i in ( “%~1” ) do set folder=%%i
for /R “%folderpath%” %%i in (*.mov *.m4v *.mp4 *.wmv *.flv *.avi *.mpeg) do (
set sourcepath=%%~di%%~pi
set destpath=!sourcepath:%folder%=mkv\%date%\!
md “!destpath!”
ffmpeg -y -i “%%~fi” -metadata title=”” -metadata comment=”” -s hd480 -aspect 16:9 -vcodec hevc -acodec aac -preset ultrafast -threads 0 “!destpath!%%~ni.mkv”
)
del “%sourcepath%”
goto :eof
::individual files
:fileonly
for %%i in (“%folderpath%”) do (
ffmpeg -y -i “%folderpath%” -metadata title=”” -metadata comment=”” -s hd480 -aspect 16:9 -vcodec hevc -acodec aac -preset ultrafast -threads 0 “!destpath!%%~ni.mkv”
)
save as .cmd
Thank you, this was *exactly* what I needed!!!
I was having the exact same frustrations you describe above, when I came across your page. Thank you so, so, so much!
Ha ha, glad this old (fairly-crappy) script was some use to someone! 🙂
Have just stumbled on this and adapted it for a vast (carefully-structured) directory of digitised cassettes. Thank you, much appreciated!!! All the best.