How to convert several files of one type (e.g. wav to mp3) using VLC or Audacity at a single blow?

4

2

I have 10 wav-Files. I want to convert all of them into mp3-Files. I managed to to this for one single file (as described in How to convert media using VLC?), but I don't want to do this for every single file. Is there a way to convert all the 10 files at a single blow? I'm using windows 7.

Semjon Mössinger

Posted 2013-07-08T15:48:15.643

Reputation: 241

2

possible duplicate of Batch convert .wav to mp3 and ogg?

– nixda – 2013-07-08T16:16:36.420

Answers

10

I followed nixda's suggestion and used a batch script. I figured out how to programm a batch for windows 7. This is my solution:

@echo off
for /f "delims=|" %%f in ('dir /b C:\Any_Directory\*.wav') do (
echo converting      %%f
CALL "C:\Program Files\VideoLAN\VLC\vlc.exe" --intf dummy --dummy-quiet "%%f" --sout="#transcode{acodec=mp3,ab=256,vcodec=dummy}:standard{access=file,mux=raw,dst=MP3_Files/"%%f"}"  vlc://quit
move "%%f" WAV_converted/"%%f"
)

cd MP3_Files
ren *.wav *.mp3
cd ..

echo .
echo .
echo .
echo conversion finished
pause

How the programm works:

  • All the files with the .wav extension in the specified folder "C:\Any_Directory\" are converted to mp3 (the file names must not contain any whitespaces)
  • The mp3 files are saved in the folder "MP3_Files" (which must already exist)
  • The wav files are pushed to the folder "WAV_converted" (which must already exist)
  • "ab=256" sets the bit rate. To convert with e.g. bit rate 128, replace it with "ab=128".
  • The batch file must be run from the same folder as the files you want to convert ( as mentioned by Kevin Heidt )

Hints - Remove "--intf dummy --dummy-quiet" from the script if you want to see the VLC GUI while converting. Could be useful for debugging.

Update There ist still one bug: If the name of the wav-file contains a dot or comma, the name is truncated (and no extension is appended!). The file gets converted despite this. Tested with Version 1.1.11. Newer versions may not work!

Added quote sign: --sout="...". Works for newer Versions, too. Tested with Version 2.1.3 64-bit on Windows (see the VLC wiki page for differences in command line for Linux and Windows and additional examples and options).

Semjon Mössinger

Posted 2013-07-08T15:48:15.643

Reputation: 241

1Note: this assumes your batch file is being run from the same folder as the files you want to convert (D:"folder xyz"\VLC_batch) – Kevin Heidt – 2015-09-16T17:40:31.037

1videolan link is dead... – Kev – 2016-03-24T13:50:35.557

This is still a good and working solution. One note; I used it to convert a load of my Soundcloud files, and all the that SC had named with a % converted to a zero length file. Easy enough to fix the filenames first though. – Whelkaholism – 2017-07-13T12:45:39.453

It also does not like parentheses in the file name. – Whelkaholism – 2017-07-13T12:48:47.907

0

I have used VLC to convert audio for a set of video files but same approach can help in any transcoding task. You should create a simple .bat file:

for %%a in (*.avi) do "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I dummy -vvv "%%a" --sout=#transcode{acodec=mp3,ab=128,channels=2,samplerate=22050}:standard{access=file,mux=ts,dst="%%a_conv.avi"} --sout-keep vlc://quit
  • This batch file will scan for all *.avi files in the same folder and transcode them with a given params described in sout=#transcode{params}
  • To know what params you should use you need select Menu->Media->Stream... and select all params in GUI wizard. At the last wizard step, you'll see generated params-string that you should use in your batch file.
  • Output files will have _conv.avi suffix, change it if you need another extension

Vadim Zin4uk

Posted 2013-07-08T15:48:15.643

Reputation: 111

0

To add a similar approach found on SO :

The changes I made , allows spaces in the directories names and in the songs names as it is often (always) the case.

@echo off
chcp 65001
SETLOCAL ENABLEDELAYEDEXPANSION

for /f "delims=" %%f IN ('dir /b /s "YOUR_DISK:\Path\To\Your Music\That May contain Spaces\*.wav"') do (
set file1=%%~nf.mp3
echo "file :" !file1!
set fic1=%%f
echo "file : " !fic1!

CALL "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"  "!fic1!" --sout="#transcode{vcodec=none,acodec=mp3,ab=320,channels=2,samplerate=48000}:std{access=file{no-overwrite},mux=mp3,dst="""!file1!"""}" vlc://quit
)

echo .
echo conversion finished
pause

Tom

Posted 2013-07-08T15:48:15.643

Reputation: 133

Nice... good job. Now to make it accept a path as an argument, and allow all acceptable characters in filenames (currently fails if filename has e.g. an '!' in it) – Krakkos – 2018-03-28T14:32:57.217