└── Handbrake.ps1 /Handbrake.ps1: -------------------------------------------------------------------------------- 1 | $dir = "$pwd" 2 | cd $dir 3 | 4 | set-Alias handbrake $pwd\HandBrakeCLI.exe 5 | 6 | $exclude = Get-Content $pwd\ExcludeList.txt 7 | 8 | $i = 0 9 | "Start Script" > $pwd\HandbrakeLog.txt 10 | 11 | $files = Get-Childitem $dir -recurse | ? { !$_.PsIsContainer -and $_.Name -match "mkv" -and $exclude -notcontains $_.FullName -and !( $_.FullName -match "N:\videos\tv\Game of Thrones" ) } 12 | "Start Script" > $pwd\Files.txt 13 | foreach ($file in $files) 14 | { 15 | $file.FullName >> $pwd\Files.txt 16 | } 17 | 18 | 19 | foreach ($file in $files) 20 | { 21 | $check = $file.DirectoryName + "\noencode" 22 | if (-not (Test-Path -Path $check)) 23 | { 24 | $newname = $file.DirectoryName + "\" + $file.BaseName + ".mp4" 25 | $newname 26 | handbrake -i $file.FullName --verbose -f av_mp4 -e x265 --encoder-preset slow -q 24.0 --vfr --native-language "eng" --audio-lang-list "eng" --aencoder ca_aac --mixdown 7point1 --auto-anamorphic --keep-display-aspect --no-comb-detect --no-deinterlace --no-decomb --no-detelecine --no-hqdn3d --no-nlmeans --no-unsharp --no-lapsharp --no-deblock --no-grayscale --subtitle scan --subtitle-forced -o $newname 27 | $log = $file.FullName 28 | $log >> $pwd\HandbrakeLog.txt 29 | $log >> $pwd\ExcludeList.txt 30 | $i++ 31 | $trash = $file.BaseName + ".Done" 32 | move-item -Path $file.FullName -Destination $pwd\Done\$trash 33 | } 34 | 35 | } 36 | 37 | 38 | if ($i -eq 0) 39 | { 40 | ' ' 41 | 'Error...' 42 | start-sleep -seconds 1 43 | ' ' 44 | 'No matching files found.' 45 | 46 | ' ' 47 | start-sleep -Seconds 1 48 | 49 | 'Script exiting...' 50 | start-sleep -Seconds 2 51 | } 52 | --------------------------------------------------------------------------------