-
-
Save woehrl01/68b8908b3d160d982cf5bdae349a1499 to your computer and use it in GitHub Desktop.
| #based on http://www.andrewconnell.com/blog/Converting-all-your-non-MP3-files-to-MP3s-with-VLC-PowerShell-and-TagLib | |
| #don't worry if there are errors shown in VLC this is perfectly fine. | |
| #there isn't any progress shown. Simply wait for completion. | |
| function ConvertToMp3 ($inputObject, [switch]$isRemoveOldFile = $false) | |
| { | |
| $vlc = "C:\Program Files\VideoLAN\VLC\vlc.exe" | |
| $codec = 'mp3'; | |
| $oldFile = $inputObject; | |
| $newFile = $inputObject.FullName.Replace("'", "\'").Replace($inputObject.Extension, ".$codec") | |
| write-host $newFile | |
| &"$vlc" -I dummy "$oldFile" ":sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst='\$newFile'}" vlc://quit | out-null | |
| if($isRemoveOldFile){ | |
| Remove-Item $oldFile; | |
| } | |
| } | |
| function ConvertAllToMp3([string] $sourcePath, [switch] $isRemoveOldFile = $false) { | |
| write-host $sourcePath | |
| Get-ChildItem "$sourcePath\*" -recurse -include *.mp4 | %{ ConvertToMp3 $_ $isRemoveOldFile} | |
| } | |
| ConvertAllToMp3 [path]; |
Yes, the $_ is the iterator variable of the powershell for-each. Which is expressed here by the % command.
It does not work, something is blocking, but no errors. If I do the conversion from the gui vlc, it just works. I am using version 3.0.11
Vielleicht hast du noch ne Idee?
If not, I can use ffmpeg.
@tik9 there is no output, it "just takes a while", so it looks blocked. Does calling the command line without the script, work for you?
In Lin12:
Where is the $_ from? I get null.
@tik9 that's strange, looks like I uploaded a bad version. It should be $inputObject of course on both places. Thank you for the hint!
Hi, I should be able to see vlc in the taskmanager, shouldn't I?
Thanks, but what is the $_ here, is it an object for the mp3?