delete_video_track_titles: add colorprint, print processed file

This commit is contained in:
Lukáš Kucharczyk 2022-10-07 22:28:06 +02:00
parent 0e53f76531
commit 17574160da
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 5 additions and 0 deletions

View File

@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
colorprint() {
echo -e "\e[31m${1}\e[0m"
}
SCRIPT_NAME=$(basename "$0") SCRIPT_NAME=$(basename "$0")
test -z "${1}" && echo "File not specified or doesn't exist, aborting. Usage: $SCRIPT_NAME \$FILENAME" && exit 1 test -z "${1}" && echo "File not specified or doesn't exist, aborting. Usage: $SCRIPT_NAME \$FILENAME" && exit 1
FILE=$1 FILE=$1
@ -7,6 +10,8 @@ FILE=$1
TRACKS=$(mkvmerge --identify "$FILE" | awk -F"[: ]" '$0 ~ /Track ID/{print $3}') TRACKS=$(mkvmerge --identify "$FILE" | awk -F"[: ]" '$0 ~ /Track ID/{print $3}')
# capture JSON output and remove the excessively large code_private_data field # capture JSON output and remove the excessively large code_private_data field
JSON_OUTPUT=$(mkvmerge -J "$FILE" | jq '.tracks[] | del(.properties.codec_private_data)') JSON_OUTPUT=$(mkvmerge -J "$FILE" | jq '.tracks[] | del(.properties.codec_private_data)')
echo -n "Processing "
colorprint "$FILE"
for TRACK in $TRACKS; do for TRACK in $TRACKS; do
TRACK_NAME=$(echo "$JSON_OUTPUT" | jq "select(.id == $TRACK).properties.track_name") TRACK_NAME=$(echo "$JSON_OUTPUT" | jq "select(.id == $TRACK).properties.track_name")
echo -n "Track no. ${TRACK} currently set to $TRACK_NAME... " echo -n "Track no. ${TRACK} currently set to $TRACK_NAME... "