Skip to content

Instantly share code, notes, and snippets.

@gabbsmo
Created April 14, 2013 22:06
Show Gist options
  • Save gabbsmo/5384440 to your computer and use it in GitHub Desktop.
Save gabbsmo/5384440 to your computer and use it in GitHub Desktop.
This PowerShell script process sets the selected audio track (1 or 2) to default in all dual audio MKV-files in a directory
#COPYRIGHT: Gabriel Smoljar (2013)
#WEBSITE: http://twitter.com/gabbsmo
#DESCRIPTION: This PowerShell script process sets the selected audio track (1 or 2)
# to default in all dual audio MKV-files in a directory
#
#NOTES: MKVPropEdit must be added to PATH for this script to work.
#DEPENDENCIES: MKVPropEdit (included in MKVToolNix http://www.bunkus.org/videotools/mkvtoolnix/)
Param(
[parameter(Mandatory=$true)]
[alias("i")]
$InputDir,
[parameter(Mandatory=$true)]
[alias("a")]
$Audio)
$items = Get-ChildItem -Path $InputDir
foreach ($item in $items)
{
if ($items.Attributes -ne "Directory")
{
$InputFile = $InputDir + "\" + $item.name
if ($item.Extension -ieq ".mkv")
{
if ($Audio -ieq "1")
{
mkvpropedit $InputFile --edit "track:a1" --set "flag-default=1" --edit "track:a2" --set "flag-default=0"
}
if ($Audio -ieq "2")
{
mkvpropedit $InputFile --edit "track:a1" --set "flag-default=0" --edit "track:a2" --set "flag-default=1"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment