Created
January 13, 2014 20:30
-
-
Save AndreiDuma/8407525 to your computer and use it in GitHub Desktop.
A little script to help with extracting subtitles from .mkv 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
#!/bin/sh | |
if ! command -v mkvmerge mkvextract >/dev/null 2>&1; then | |
echo >&2 "Tools mkvmerge & mkvextract are required. Install package mkvtoolnix." | |
exit 1 | |
fi | |
filename=$1 | |
if [ ! -f $filename ]; then | |
echo "File not found." | |
exit 1 | |
fi | |
filename_no_ext=$(echo $1 | sed -r 's/.mkv//') | |
sed_exp='s/.*([0-9]+):.*language:([a-z]+).*/\1:'$filename_no_ext'.\2.\1.srt/' | |
mkvmerge -I $filename | grep subtitles | sed -r $sed_exp | xargs mkvextract tracks $filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And in order to make this work with filenames containing the path, you need to do this:
filename_no_ext=$(basename $1 .mkv)