Skip to content

Instantly share code, notes, and snippets.

@hansdg1
Last active June 19, 2016 06:33
Show Gist options
  • Save hansdg1/707596cee41fc9ace31c10e445f30180 to your computer and use it in GitHub Desktop.
Save hansdg1/707596cee41fc9ace31c10e445f30180 to your computer and use it in GitHub Desktop.
# Author: Hans Guthrie
# Date: 6/19/2016
# Purpose: Set audio track language to English for all mkvs in current and subfolders
# Future: Support multiple audio tracks, allow update individual tracks or all,
# Test mode using an argument
#find . -type f -iname *.mkv -print0 | xargs -0
unmodified=/tmp/unmodified-eng.tmp
modified=/tmp/modified-eng.tmp
echo 0 > $unmodified
echo 0 > $modified
find . -iname '*.mkv' | while read line; do
echo "$line"
language=$(mediainfo --inform="Audio;%Language%" "$line")
#if [[ `mediainfo --inform="Audio;%Language%"`= "" ]]
if [[ "$language" ]]
then
echo "Already set to: $language"
countunmodified=$[$(cat $unmodified) + 1]
else
mkvpropedit "$line" --edit track:a1 --set language=eng;
echo "Empty!"
countmodified=$[$(cat $modified) + 1]
fi
echo $countunmodified > $unmodified
echo $countmodified > $modified
done
printf "****************************\nUnmodified Files: %d\nModified Files: %d\n****************************" `cat $unmodified` `cat $modified`
unlink $modified
unlink $unmodified
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment