-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLI_mkv_batch_chflags.sh
108 lines (91 loc) · 2.74 KB
/
CLI_mkv_batch_chflags.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
#
# Requires mkvtoolnix
#
# Usage : bash mkv_batch_chflags.sh <directory>
#
# To configure see the SETTINGS section below.
#
### TEST DEPENDENCIES ###
#-- MKVPROPEDIT --#
command -v mkvpropedit >/dev/null 2>&1 || if [[ $? -ne 0 ]] ; then
echo -e "${RED}Error${NC} : ${YELLOW}mkvpropedit${NC} is missing, please install ${YELLOW}mkvtoolnix${NC} package."
exit
fi
#-- MKVINFO --#
command -v mkvinfo >/dev/null 2>&1 || if [[ $? -ne 0 ]] ; then
echo -e "${RED}Error${NC} : ${YELLOW}mkvinfo${NC} is missing, please install ${YELLOW}mkvtoolnix${NC} package."
exit
fi
### CHECK ARGUMENT PRESENCE ###
if [[ -z $1 ]]
then
echo -e "${RED}Error${NC} : No folder provided in argument, please specify a folder."
exit
fi
### CHECK FOLDER ###
if [ ! -d $1 ]; then
echo -e "${RED}Error${NC} : folder $1 incorrect or missing. (Wrong path, or missing ending \"/\" ?)"
exit
fi
### ASKS IF SURE OF CONFIG ###
clear
echo -e "-- Batch change MKV flags ---"
echo ""
echo -e "Warning !"
echo ""
echo -e "This tool is about to modify ALL mkv files contained in folder $1."
echo -e "You must edit its settings according to mkvinfo."
echo ""
read -e -p "Are you sure of its config (Y/N) ? " IS_SURE
echo ""
if [[ "$IS_SURE" = "y" ]] || [[ "$IS_SURE" = "Y" ]]; then
OIFS="$IFS"
IFS=$'\n'
for file in $1*.mkv
do
#-- Show filename being processed --#
echo $file
### SETTINGS ###
# Change theese settings according to mkvinfo
#
# Example below un-sets enabled, default and forced flags
# for track 2 & 4, and sets unable & default for track 3
#
# You can add or delete lines below according to mkvpropedit syntax
#
# Echos are only here for keeping track of progress and eye candy.
echo ""
echo -e "Pass 1"
echo ""
echo -e "Disabling track 2 force flag."
mkvpropedit "${file}" --edit track:2 --set flag-forced=0
echo -e "Disabling track 2 enabled flag."
mkvpropedit "${file}" --edit track:2 --set flag-enabled=0
echo -e "Disabling track 2 default flag."
mkvpropedit "${file}" --edit track:2 --set flag-default=0
echo ""
echo -e "Pass 2"
echo ""
echo -e "Disabling track 4 default flag."
mkvpropedit "${file}" --edit track:4 --set flag-default=0
echo -e "Disabling track 4 enabled flag."
mkvpropedit "${file}" --edit track:4 --set flag-enabled=0
echo -e "Disabling track 4 forced flag."
mkvpropedit "${file}" --edit track:4 --set flag-forced=0
echo ""
echo -e "Pass 3"
echo ""
echo -e "Disabling track 3 forced flag."
mkvpropedit "${file}" --edit track:3 --set flag-forced=0
echo -e "Enabling track 3 enabled flag."
mkvpropedit "${file}" --edit track:3 --set flag-enabled=1
echo -e "Enabling track 3 default flag."
mkvpropedit "${file}" --edit track:3 --set flag-default=1
### END OF SETTINGS ###
done
IFS="$OIFS"
else
echo "Exiting."
exit
fi