Skip to content

Instantly share code, notes, and snippets.

@Nepomuk
Created November 20, 2017 10:00
Show Gist options
  • Save Nepomuk/07daa4fb286d6168d56841703369aa36 to your computer and use it in GitHub Desktop.
Save Nepomuk/07daa4fb286d6168d56841703369aa36 to your computer and use it in GitHub Desktop.
Keep only the English audio track of a mkv file.
#!/bin/bash
directory=$1
dest=/Volumes/Andre_800G/Serien/ready/
destBin="done"
cd $directory
if [ ! -d "$destBin" ]; then
echo "Creating folder $destBin..."
mkdir $destBin
fi
shopt -s nullglob
for f in *.mkv
do
echo "Processing file $f..."
trackID=$(mkvmerge -I "$f" | sed -En 's/Track ID ([0-9]*): audio.*language:eng.*/\1/p')
mkvmerge -o "$dest/$f" -a $trackID "$f"
echo "Move the file to the \'$done\' folder."
mv "$f" $destBin
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment