From 82dafd7e902f01310cfe0eb87f267b185ab7ff59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Sat, 9 Jul 2022 21:18:04 +0200 Subject: [PATCH] add delete_video_track_titles --- delete_video_track_titles.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 delete_video_track_titles.sh diff --git a/delete_video_track_titles.sh b/delete_video_track_titles.sh new file mode 100755 index 0000000..49158c2 --- /dev/null +++ b/delete_video_track_titles.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +SCRIPT_NAME=$(basename "$0") +test -z "${1}" && echo "File not specified or doesn't exist, aborting. Usage: $SCRIPT_NAME \$FILENAME" && exit 1 +FILE=$1 +# TODO: use -J and jq '.tracks[] | [.properties.number, .type, .codec, .properties.track_name]' +TRACKS=$(mkvmerge --identify "$FILE" | awk -F"[: ]" '$0 ~ /Track ID/{print $3}') +# capture JSON output and remove the excessively large code_private_data field +JSON_OUTPUT=$(mkvmerge -J "$FILE" | jq '.tracks[] | del(.properties.codec_private_data)') +for TRACK in $TRACKS; do + TRACK_NAME=$(echo "$JSON_OUTPUT" | jq "select(.id == $TRACK).properties.track_name") + echo -n "Track no. ${TRACK} currently set to $TRACK_NAME... " + shopt -s nocasematch + [[ $TRACK_NAME =~ full|titles|comment|director ]] && echo "includes whitelisted word, not deleting." && continue + echo "deleting." + # mkvmerge --identify indexes tracks from 0, while mkvpropedit indexes from 1 + mkvpropedit "$FILE" --edit track:"$((TRACK+1))" --delete name +done +echo "Deleting file title..." +mkvpropedit "$FILE" --edit info --delete title \ No newline at end of file