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:
vlc.exe -I dummy old.m4a :sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst=new.mp3} vlc://quit
Let’s wrap this command in a bit of 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;
}
}
And now we can use this function for *all* m4a files in a given folder:
function ConvertAllToMp3([string] $sourcePath) {
Get-ChildItem "$sourcePath\*" -recurse -include *.m4a | ConvertToMp3;
}
Using the function is as easy as:
ConvertAllToMp3 'C:\Users\timvw\Music';