Petites améliorations #129
@ -24,8 +24,11 @@
|
||||
## ##
|
||||
##==============================================================================================
|
||||
|
||||
Clear-Host
|
||||
|
||||
# Set MKVMerge.exe Path
|
||||
$MKVMerge = "`"H:\z_MKV\mkvtoolnix\mkvmerge.exe`""
|
||||
# For the parameters to pass to MKVMerge executable, will be construct
|
||||
|
||||
#Set Source and Target directories (Don't put an \ at the end)
|
||||
$sourceDirectory_1 = "PATH_TO_SOURCE_1"
|
||||
@ -33,14 +36,19 @@ $sourceDirectory_2 = "PATH_TO_SOURCE_2"
|
||||
$destinationDirectory = "PATH_TO_DESTINATION"
|
||||
|
||||
# Rename output file with this settings :
|
||||
$chain_to_search = '(.*).S(\d*)E(\d*).(.*)H264(.*)'
|
||||
#$chain_to_search = '(\w+)\.S(\d{2})E(\d{2}).720p.(.*)x264(.*)'
|
||||
$chain__to_replace = '$1 (2003) - S$2E$3 - $4x265-10bits$5--Reencoded'
|
||||
# $chain_to_search = '(\w+)\.S(\d{2})E(\d{2}).(.*)H264(.*)'
|
||||
$chain_to_search = '(\w+)\.S(\d{2})E(\d{2})(.*)1080p.(.*)H.264(.*)'
|
||||
# $chain__to_replace = '$1 - S$2E$3 - $4x265-10bits$5--Reencoded'
|
||||
$chain__to_replace = '$1 (2021) - S$2E$3 - 1080p.$5x265-10bits$6--Reencoded'
|
||||
|
||||
# The filenames must be like : blabla.S00E00.blabla.H.264.blabla
|
||||
# They will be renamed to : blabla - S00E00 - blabla.x265-10bits.blabla--Reencoded
|
||||
# If you don't want the rename to be made, juste set to '' the variables.
|
||||
|
||||
# If there is no internal subtitles to keep :
|
||||
# Set to $false for no internal subtitle
|
||||
# Set to $true for one or more internal subtitles
|
||||
$Internal_SUB = $true
|
||||
|
||||
# Is there an external subtitle ? Set the number of .SRT (0 - 2)
|
||||
# It's exclusive, no internal SUB will be proceed..
|
||||
@ -55,6 +63,11 @@ $SubExtension_2 = 'fre.srt'
|
||||
#If source and destination are the same folder, set this to True, Otherwise let it to "False"
|
||||
$merged_SUFFIX_name = "False"
|
||||
|
||||
# Move MKV1 (and SRT) to Not-Merged folder ? Set to $false or $true
|
||||
$move_mkv1_after_merge = $true
|
||||
# Move MKV2 (and SRT) to Not-Merged folder ? Set to $false or $true
|
||||
$move_mkv1_after_merge = $true
|
||||
|
||||
# Initialization for those 2 variables, do not change them !
|
||||
$MKVMerge_sub_param = ""
|
||||
$MKVMerge_audio_param = ""
|
||||
@ -64,22 +77,22 @@ $MKVMerge_audio_param = ""
|
||||
# ================== AUDIO ==================
|
||||
# Track 1 = Audio n°1
|
||||
# Name and language of Audio Track n°1
|
||||
$AudioTrackName_1 = "`"1:English - DDP 5.1`""
|
||||
$AudioLang_1 = "1:en"
|
||||
$AudioTrackName_1 = "1:English - DDP 5.1"
|
||||
$AudioLang_1 = "1:fr"
|
||||
$AudioTrack_1_default = "1:yes"
|
||||
# Define track order
|
||||
# Define track order. Do not modify it unless you changed the track number in this section
|
||||
$track_order = "1:0,0:1"
|
||||
# $MKVMerge_audio_param = '--language', "$AudioLang_1", '--track-name', "$AudioTrackName_1", '--default-track', "$AudioTrack_1_default"
|
||||
$MKVMerge_audio_param = "--language $AudioLang_1 --track-name $AudioTrackName_1 --default-track $AudioTrack_1_default"
|
||||
$MKVMerge_audio_param = "--language $AudioLang_1 --track-name `"$AudioTrackName_1`" --default-track $AudioTrack_1_default"
|
||||
|
||||
# # Track 2 = Audio n°2
|
||||
# # Name and language of Audio Track n°2
|
||||
# $AudioTrackName_1 = "`"2:English - DDP 5.1`""
|
||||
# $AudioTrackName_1 = "2:English - DDP 5.1"
|
||||
# $AudioLang_1 = "2:en"
|
||||
# $AudioTrack_1_default = "2:yes"
|
||||
# # Define track order
|
||||
# # Define track order. Do not modify it unless you changed the track number in this section
|
||||
# $track_order = "1:0,0:1,0:2"
|
||||
# $MKVMerge_audio_param += "--language $AudioLang_2 --track-name $AudioTrackName_2 --default-track $AudioTrack_2_default"
|
||||
# $MKVMerge_audio_param += "--language $AudioLang_2 --track-name `"$AudioTrackName_2`" --default-track $AudioTrack_2_default"
|
||||
|
||||
##########################################
|
||||
#### FILE 2 - MKV - Keeping only the video
|
||||
@ -115,29 +128,35 @@ if ( $NB_External_SUB -ne 0 ) {
|
||||
}
|
||||
else {
|
||||
# ================== INTERNAL SUBTITLES ==================
|
||||
# Track 2 = Sub n°1 to keep
|
||||
# Name and language of Subtitle Track n°1 + Sync Value
|
||||
$SubTrackName_1 = "`"2:English - SRT`""
|
||||
$SubTrackLang_1 = "2:en"
|
||||
$SubTrack_1_default = "2:yes"
|
||||
$sub_charset_1 = "2:UTF-8"
|
||||
# Define track order
|
||||
$track_order += ",0:2"
|
||||
$subtitle_tracks = "2"
|
||||
# $MKVMerge_sub_param = '--sub-charset', "$sub_charset_1", '--language', "$SubTrackLang_1", '--track-name', "$SubTrackName_1", '--default-track', "$SubTrack_1_default"
|
||||
$MKVMerge_sub_param = "--sub-charset $sub_charset_1 --language $SubTrackLang_1 --track-name $SubTrackName_1 --default-track $SubTrack_1_default"
|
||||
if ( $Internal_SUB -eq $false ) {
|
||||
# Track 2 = Sub n°1 to keep
|
||||
# Name and language of Subtitle Track n°1 + Sync Value
|
||||
# $SubTrackName_1 = "2:English - SRT"
|
||||
# $SubTrackLang_1 = "2:en"
|
||||
# $SubTrack_1_default = "2:yes"
|
||||
# $sub_charset_1 = "2:UTF-8"
|
||||
# # Define track order
|
||||
# $track_order += ",0:2"
|
||||
# $subtitle_tracks = "2"
|
||||
# # $MKVMerge_sub_param = '--sub-charset', "$sub_charset_1", '--language', "$SubTrackLang_1", '--track-name', "$SubTrackName_1", '--default-track', "$SubTrack_1_default"
|
||||
# $MKVMerge_sub_param = "--sub-charset $sub_charset_1 --language $SubTrackLang_1 --track-name `"$SubTrackName_2`" --default-track $SubTrack_1_default"
|
||||
|
||||
# Track 3 = Sub n°2 to keep
|
||||
# Name and language of Subtitle Track n°1 + Sync Value
|
||||
# $SubTrackName_1 = "3:English SDH - SRT"
|
||||
# $SubTrackLang_1 = "3:eng"
|
||||
# $SubTrack_1_default = "3:yes"
|
||||
# $sub_charset_1 = "3:UTF-8"
|
||||
# # Define track order
|
||||
# $track_order += ",0:3"
|
||||
# $subtitle_tracks = "3"
|
||||
# $MKVMerge_sub_param += "--sub-charset $sub_charset_2 --language $SubTrackLang_2 --track-name $SubTrackName_2 --default-track $SubTrack_2_default"
|
||||
####
|
||||
# Track 3 = Sub n°2 to keep
|
||||
# Name and language of Subtitle Track n°1 + Sync Value
|
||||
$SubTrackName_2 = "3:English SDH - SRT"
|
||||
$SubTrackLang_2 = "3:eng"
|
||||
$SubTrack_2_default = "3:yes"
|
||||
$sub_charset_2 = "3:UTF-8"
|
||||
# Define track order
|
||||
$track_order += ",0:3"
|
||||
$subtitle_tracks = "3"
|
||||
$MKVMerge_sub_param += "--sub-charset $sub_charset_2 --language $SubTrackLang_2 --track-name `"$SubTrackName_2`" --default-track $SubTrack_2_default"
|
||||
####
|
||||
}
|
||||
else {
|
||||
# No internal subtitles are to be kept...
|
||||
$MKVMerge_sub_param = ""
|
||||
}
|
||||
}
|
||||
## End of part where there is something to change !
|
||||
##==============================================================================================
|
||||
@ -304,11 +323,9 @@ Foreach ($MKV_1 in $MKV_1_List) {
|
||||
# Set Output File Name
|
||||
If ($merged_SUFFIX_name -eq "True") {
|
||||
$Output = $destinationDirectory + "\" + $VideoTrackName + '___MERGED' + '.mkv'
|
||||
$Output = "`"$Output`""
|
||||
} elseif ($merged_SUFFIX_name -eq "False") {
|
||||
# $Output = $destinationDirectory + "\" + $VideoTrackName + '.mkv'
|
||||
$Output = "$destinationDirectory" + "\" + "$VideoTrackName" + ".mkv"
|
||||
$Output = "`"$Output`""
|
||||
} else {
|
||||
write-host "Error in the value of the merged_SUFFIX_name variable. Current value = $merged_SUFFIX_name" -ForegroundColor "red"
|
||||
write-host "Should be set to True or False.`nScript is exiting now..." -ForegroundColor "white"
|
||||
@ -328,7 +345,7 @@ Foreach ($MKV_1 in $MKV_1_List) {
|
||||
$SRT_1_Name = $MKV_1_name + ".$SubExtension_1"
|
||||
$SRT_1 = $sourceDirectory_1 + "\" + $SRT_1_name
|
||||
|
||||
$MKVMerge_param_start = "---output $Output --title `"$VideoTrackName`" --track-order `"$track_order`" --no-video --no-subtitles"
|
||||
$MKVMerge_param_start = "---output `"$Output`" --title `"$VideoTrackName`" --track-order `"$track_order`" --no-video --no-subtitles"
|
||||
$MKVMerge_param_mkv1 = "$MKVMerge_audio_param `"$MKV_1`""
|
||||
$MKVMerge_param_mkv2 = "--no-audio --no-track-tags --no-global-tags --language 0:en --track-name `"0:$VideoTrackName`" --default-track 0:yes --no-subtitles --no-audio `"$MKV_2`""
|
||||
|
||||
@ -350,9 +367,15 @@ Foreach ($MKV_1 in $MKV_1_List) {
|
||||
}
|
||||
else {
|
||||
# INTERNAL SUB to keep
|
||||
|
||||
$MKVMerge_param_start = "--output $Output --title `"$VideoTrackName`" --track-order `"$track_order`" --subtitle-tracks $subtitle_tracks --no-video"
|
||||
$MKVMerge_param_mkv1 = "$MKVMerge_audio_param $MKVMerge_sub_param `"$MKV_1`""
|
||||
$MKVMerge_param_start = "--output `"$Output`" --title `"$VideoTrackName`" --track-order `"$track_order`" --subtitle-tracks $subtitle_tracks --no-video"
|
||||
if ( $Internal_SUB -eq $true ) {
|
||||
# There is some internal subtitles to keep
|
||||
$MKVMerge_param_mkv1 = "$MKVMerge_audio_param $MKVMerge_sub_param `"$MKV_1`""
|
||||
}
|
||||
else {
|
||||
# There is no internal subtitles to keep
|
||||
$MKVMerge_param_mkv1 = "$MKVMerge_audio_param `"$MKV_1`""
|
||||
}
|
||||
$MKVMerge_param_mkv2 = "--no-audio --no-track-tags --no-global-tags --language 0:en --track-name `"0:$VideoTrackName`" --default-track 0:yes --no-subtitles --no-audio `"$MKV_2`""
|
||||
|
||||
$MKVMerge_param_all = "$MKVMerge_param_start $MKVMerge_param_mkv1 $MKVMerge_param_mkv2"
|
||||
@ -387,15 +410,18 @@ Foreach ($MKV_1 in $MKV_1_List) {
|
||||
#Remove-Item $Sub
|
||||
#Remove-Item $OtherSub
|
||||
# Move to folder Not-Merged, this folder's existence has already been tested, and the folder is created.
|
||||
Move-Item -Path $MKV_1 -Destination $Path_Folder_NotMerged_1 -Verbose
|
||||
Move-Item -Path $MKV_2 -Destination $Path_Folder_NotMerged_2 -Verbose
|
||||
|
||||
if ( $NB_External_SUB -ne 0 ) {
|
||||
Move-Item -Path $SRT_1 -Destination $Path_Folder_NotMerged_1 -Verbose
|
||||
if ( $NB_External_SUB -eq 2 ) {
|
||||
Move-Item -Path $SRT_2 -Destination $Path_Folder_NotMerged_2 -Verbose
|
||||
if ( $move_mkv1_after_merge -eq $true ) {
|
||||
Move-Item -Path $MKV_1 -Destination $Path_Folder_NotMerged_1 -Verbose
|
||||
if ( $NB_External_SUB -ne 0 ) {
|
||||
Move-Item -Path $SRT_1 -Destination $Path_Folder_NotMerged_1 -Verbose
|
||||
if ( $NB_External_SUB -eq 2 ) {
|
||||
Move-Item -Path $SRT_2 -Destination $Path_Folder_NotMerged_2 -Verbose
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $move_mkv2_after_merge -eq $true ) {
|
||||
Move-Item -Path $MKV_2 -Destination $Path_Folder_NotMerged_2 -Verbose
|
||||
}
|
||||
}
|
||||
Else {
|
||||
write-host "File NON-EXISTANT - $Output" -foreground "red"
|
||||
|
Loading…
Reference in New Issue
Block a user