Convert AAC/M4A files to MP3 with VLC and PowerShell

Here is a way to convert your AAC/M4A files to MP3 using VLC media player:

[code lang=”text”]
vlc.exe -I dummy old.m4a :sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst=new.mp3} vlc://quit
[/code]

Let’s wrap this command in a bit of PowerShell:

[code lang=”powershell”]
function ConvertToMp3([switch] $inputObject, [string] $vlc = ‘C:\Program Files\VideoLAN\VLC\vlc.exe’) {
PROCESS {
$codec = ‘mp3’;
$oldFile = $_;
$newFile = $oldFile.FullName.Replace($oldFile.Extension, ".$codec");
&"$vlc" -I dummy "$oldFile" ":sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst='$newFile‘}" vlc://quit | out-null;
#Only remove source files when you are sure that the conversion works as you want
#Remove-Item $oldFile;
}
}
[/code]

And now we can use this function for *all* m4a files in a given folder:

[code lang=”powershell”]
function ConvertAllToMp3([string] $sourcePath) {
Get-ChildItem "$sourcePath\*" -recurse -include *.m4a | ConvertToMp3;
}
[/code]

Using the function is as easy as:

[code lang=”powershell”]
ConvertAllToMp3 ‘C:\Users\timvw\Music’;
[/code]

One thought on “Convert AAC/M4A files to MP3 with VLC and PowerShell

  1. Pingback: Batch convert audio files to MP3 with PowerShell and VLC Player - roadha.us

Comments are closed.