Skip to content

Instantly share code, notes, and snippets.

@Alistair1231
Created March 22, 2021 10:24
Show Gist options
  • Save Alistair1231/8a0861464df0e85cdc93a35299f2e8b2 to your computer and use it in GitHub Desktop.
Save Alistair1231/8a0861464df0e85cdc93a35299f2e8b2 to your computer and use it in GitHub Desktop.
Change MKV Title to part of filename for all files in folder
# path to mkvpropedit
$propedit = "mkvpropedit"
# path where files are
$path="D:\!USENET\!Anime\Hunter X Hunter (2011)"
#substring vals
$skipCharacters=14
$saveCharacters=28
#example: skip 14, save 28
# [GHOST][720p] Hunter x Hunter (2011) - 034 [BD HEVC 10bit Dual Audio AC3][67AC64E3]
# becomes
# Hunter x Hunter (2011) - 034
Set-Location $path
$files = Get-ChildItem $path -Filter *.mkv
for ($i=0; $i -lt $files.Count; $i++) {
$file = ("{0}{1}" -f $files[$i].BaseName,$files[$i].Extension)
$name = $file.Substring($skipCharacters,$saveCharacters) #skip 14, save 28
$command = ("{0} '{1}' -e info -s title='{2}'" -f $propedit, $file, $name)
Invoke-Expression -Command $command
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment