VLC batch convert to mp3

What I wanted

Convert a single(!) file (mp4, flv, …) to mp3 using VLC via command line and trash the original video without having to re-type all the VLC stuff over and over again.

How I did it

I wrote a very simple batch file that does the work for me.
Here’s my setup:
I have a directory containing all the stuff I want to convert. Within that directory there’s a directory called „converted“ and another one called „trash“. converted will contain the converted mp3 files and trash will hold the original files (just in case something went wrong during convert).
Place the following convert.bat in the setup’s root directory:

set inname=%1
@echo in: %inname%

set outname=%inname:~0,-5%.mp3"
@echo out: %outname%

:: convert
CALL "C:\Program Files\Videolan\VLC\vlc.exe" %inname% --sout=#transcode{acodec=mp3,vcodec=dummy}:standard{access=file,mux=raw,dst=converted/%outname%} vlc://quit

:: move original to pseudo trash
move %1 trash/%1

Assuming you have VLC installed (and mp3 codecs) you can now press Win+R, hack in cmd, navigate to your setup (cd command), and run convert.bat „my super cool video that needs to become a mp3.mp4“

What’s the outcome

You will now have VLC popping up and writing to converted/my super cool video that needs to become a mp3.mp3. After it’s done it will move the original to the trash directory.

But I want it to convert all the files at once

There’s plenty of tutorial on the interwebs for this.

Why not move the original to the actual system trash?

I’m just too lazy to do that. This way, if anything went wrong and I need the original I won’t have to search my 300 kajillion trashfiles for the original but my 20 trashed videos – that’s way faster. And if everything went as expected I can move the whole trash directory to the actual trash (and create a new one).

I don’t want the VLC window to pop up

There’s a dummy option for you.

What’s your system?

I’m running Windows 7 ultimate with VLC 2.1.0 (beta).
I had some converting issues with VLC 2.0.

What could be done better if I wasn’t that lazy and actually knew how to batch

  • Actually trash the original if VLC exits without an error and the file has been written.
  • Accept a second parameter that – when given – is the new file name/location.
  • Automatically add mp3 metadata (well, batch won’t do that alone).
  • Add option to convert n/all files at once.
  • Verbose/non-verbose option
  • Sample rate/output encoding/… options
  • and so on