- Code: Select all
#!/bin/bash
# On the even of crash or exit - probably the most powerful advanced bash trigger IMHO is trap. Second to none, minus utilizing arrays.
function finish {
if [[ -f "TEMP.MKV" ]]; then
rm "TEMP.MKV"
fi
}
trap finish EXIT
if [[ -f "TEMP.MKV" ]]; then
rm "TEMP.MKV"
fi
shopt -s nullglob
declare -a MOVIES=();
MOVIES=(*.mkv)
if ! [[ "$1" ]]; then
for EACH in "${MOVIES[@]}"
do
echo "Stripping Subtitles from $EACH to TEMP.MKV"
mkvmerge --no-subtitles "$EACH" -o TEMP.MKV
if [[ -s "TEMP.MKV" ]]; then
rm "$EACH"
echo "Processing ffmpeg -i TEMP.MKV -c:s copy -c:v copy -c:a ac3 $EACH"
ffmpeg -i TEMP.MKV -c:s copy -c:v copy -c:a ac3 "$EACH"
fi
if [[ -s "TEMP.MKV" ]]; then
echo "Removing TEMP.MKV"
rm TEMP.MKV
fi
done
else
if [[ -f "$1" ]]; then
EACH="$1"
echo "Stripping Subtitles from $EACH to TEMP.MKV"
mkvmerge --no-subtitles "$EACH" -o TEMP.MKV
if [[ -s "TEMP.MKV" ]]; then
rm "$EACH"
echo "Processing ffmpeg -i TEMP.MKV -c:s copy -c:v copy -c:a ac3 $EACH"
ffmpeg -i TEMP.MKV -c:s copy -c:v copy -c:a ac3 "$EACH"
if [[ -f "$EACH" ]]; then
rm "TEMP.MKV"
fi
fi
if [[ -s "TEMP.MKV" ]]; then
echo "Removing TEMP.MKV"
rm TEMP.MKV "$EACH"
fi
else
echo "$1 does not exist. Exiting."
fi
fi
No help system yet, feel free to test it out and enjoy. Remove the subtitle destruction and it straight up rocks.
TheeMahn,