Gabe Farrell 9 months ago
parent b795c0d001
commit ac47243eb4

@ -0,0 +1,6 @@
# TODO
[ ] Write script to remove images embedded in mkv
[ ] Write script to remove unwanted audio tracks in mkv
[ ] Write script to remove unwanted subtitle tracks in mkv
[ ] Write script to discard PGS subtitle tracks if ASS subtitle tracks exist
[ ] Write a script to make the first audio track in a language the default

@ -1,18 +1,29 @@
#!/bin/bash
# Function to check attachments in a file
# Function to check if the file contains SSA/ASS subtitles
contains_ssa_ass() {
local file="$1"
if mkvmerge -i "$file" | grep -iqE "subtitles.*\(SSA\|ASS\)"; then
return 0 # Found SSA/ASS subtitles
else
return 1 # No SSA/ASS subtitles
fi
}
# Function to check if the file has attachments
check_attachments() {
local file="$1"
# Use mkvinfo to get the details of the file, specifically looking for 'attachments'
if ! mkvmerge -i "$file" | grep -q "Attachment"; then
# If there are no attachments, print the filename
if ! mkvinfo "$file" | grep -q "Attachment"; then
echo "$file"
fi
}
# Export the function so it can be used with find
export -f contains_ssa_ass
export -f check_attachments
# Recursively find all .mkv files and check for attachments
find . -type f -name "*.mkv" -exec bash -c 'check_attachments "$0"' {} \;
# Find all .mkv files and process them
find . -type f -name "*.mkv" | while read -r file; do
if contains_ssa_ass "$file"; then
check_attachments "$file"
fi
done

Loading…
Cancel
Save