Skip to content

Instantly share code, notes, and snippets.

@hansgafriedzal
Created May 1, 2023 16:06
Show Gist options
  • Save hansgafriedzal/86e9f5020ff0b51a15b09667fcc45b2d to your computer and use it in GitHub Desktop.
Save hansgafriedzal/86e9f5020ff0b51a15b09667fcc45b2d to your computer and use it in GitHub Desktop.
dir $PSScriptRoot\*\Subs | foreach {
$_.Parent.FullName
$movieDir = $_.Parent.FullName
cd $movieDir
$movieFileName = dir *.mkv, *.mp4, *.avi | select -ExpandProperty BaseName -First 1
cd $_
dir *.srt | where BaseName -like *english* | sort Length -Descending | select -First 1 | foreach {
$newSub = $movieFileName + '.en' + $_.Extension
if (Test-Path ($movieDir + '\' + $newSub)) {} else {
copy $_ $movieDir
ren ($movieDir + '\' + $_.Name) $newSub
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment