Skip to content

Instantly share code, notes, and snippets.

@glitchedmob
Created December 28, 2016 15:08
Show Gist options
  • Save glitchedmob/54eb8617d1bd835a76b0b81c4667a7c1 to your computer and use it in GitHub Desktop.
Save glitchedmob/54eb8617d1bd835a76b0b81c4667a7c1 to your computer and use it in GitHub Desktop.
A powershell script that uses VLC's audio codecs to convert multiple file in different audio formats to .mp3
function ConvertToMp3([switch] $inputObject, [string] $vlc = 'C:\Program Files\VideoLAN\VLC\vlc.exe') {
process {
Write-Host $_
$codec = 'mp3'
$newFile = $_.FullName.Replace("'", "\'").Replace($_.Extension, ".$codec")
&"$vlc" -I dummy "$_" ":sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst=`'$newFile`'}" vlc://quit | out-null
# Uncomment the next line when you're sure everything is working right
#Remove-Item $_.FullName.Replace('[', '`[').Replace(']', '`]')
}
}
function ConvertAllToMp3([string] $sourcePath) {
Get-ChildItem "$sourcePath\*" -recurse -include *.wma,*.aac,*.ogg,*.m4a | ConvertToMp3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment