Skip to content

Instantly share code, notes, and snippets.

@jwallet
jwallet / Microsoft.PowerShell_profile.ps1
Last active December 9, 2023 00:46
Windows Powershell functions to convert video files with mkvmerge from mp4 and avi to mkv and set all mkv default audio and video language to your desired language with mkvpropedit all in batch to be used for your PLEX server or something else.
# Credit: https://www.github.com/jwallet
function mkv-set-language([string]$lang="eng") {
Get-ChildItem -Path "." -Name -Recurse -File -Include *.mkv | ForEach { echo ">>> Getting file: $_"; Set-ItemProperty $_ -name IsReadOnly -value $false | & 'C:\Program Files (x86)\MKVToolNix\mkvpropedit.exe' --tags all:'' --delete title --edit track:v1 --set language=$lang --edit track:a1 --set language=$lang "$_" }
}
function to-mkv([string]$lang="eng") {
Get-ChildItem -Path "." -Name -Recurse -File -Include *.avi,*.mp4 | ForEach { echo ">>> Getting file: $_"; $_ -match '(?<filename>.*)[.]'; $output = $matches["filename"] + ".mkv"; Set-ItemProperty $_ -name IsReadOnly -value $false | & 'C:\Program Files (x86)\MKVToolNix\mkvmerge.exe' -o $output --default-language $lang "$_" }; mkv-set-language $lang;
}