Created
November 22, 2023 02:52
-
-
Save gbonk/600f3a8b1d384007d66700a12a467d79 to your computer and use it in GitHub Desktop.
Find media files that already have subs and delete any sub files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
OIFS="$IFS" | |
IFS=$'\n' | |
for mfile in $(find /mnt/movies -type f -name '*.mkv' -o -name '*.mp4'); do | |
echo "Checking: " $(basename "$mfile" ) | |
has_subs="$( timeout 60 mediainfo '--Output=Text;%Language/String%, ' $mfile | grep -i 'english,' )" | |
exit_code="$?" | |
if [[ $exit_code == 124 ]]; then | |
echo "TIMEOUT" | |
has_subs="" | |
fi | |
if [[ -n $has_subs ]]; then | |
echo "Subs!" | |
dfile="$(dirname $mfile)" | |
ls -lR "$dfile/"*.srt | |
rm -f "$dfile/"*.srt | |
else | |
echo "NO Subs" | |
fi | |
done | |
IFS="$OIFS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment