You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
scripts/set_anime_sub_titles.sh

33 lines
926 B

#!/bin/bash
# Ensure mkvpropedit and mkvmerge are installed
if ! command -v mkvpropedit &> /dev/null || ! command -v mkvmerge &> /dev/null; then
echo "Error: mkvpropedit and mkvmerge are required. Please install mkvtoolnix."
exit 1
fi
# Check if input file is provided
if [[ -z "$1" ]]; then
echo "Usage: $0 <input.mkv>"
exit 1
fi
INPUT_FILE="$1"
echo "Processing: $INPUT_FILE"
# Get all subtitle track IDs
subtitle_tracks=($(mkvmerge -i "$INPUT_FILE" | awk -F ': ' '/subtitles/ {print $1}' | awk '{print $3}'))
if [[ ${#subtitle_tracks[@]} -gt 0 ]]; then
echo "Setting track:s1 name to Dialogue"
mkvpropedit "$INPUT_FILE" --edit track:s1 --set name="Dialogue"
if [[ ${#subtitle_tracks[@]} -gt 1 ]]; then
echo "Setting track:s2 name to Signs & Songs"
mkvpropedit "$INPUT_FILE" --edit track:s2 --set name="Signs & Songs"
fi
fi
echo "Subtitle track titles updated successfully."