Skip to content

Instantly share code, notes, and snippets.

@ncode
Created July 13, 2012 03:02
Show Gist options
  • Save ncode/3102422 to your computer and use it in GitHub Desktop.
Save ncode/3102422 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ ${#} != 1 ] ; then
echo "Usage ${0/*\/} file"
exit
fi
file=$1
ext=${file/*./}
sub_id=$(mkvinfo ${file} | awk '
BEGIN { id=0 } {
if ( $0 ~ /mkvextract:/ ){
gsub(/)/,"")
id=$NF
} else if ( $0 ~ /Codec ID: S_TEXT/){
print id
}
}')
if [ ! -h "${file/$ext/avi}" ] ; then
ln -s $file ${file/$ext/avi}
fi
mkvextract tracks ${file} ${sub_id}:${file/$ext/srt}
ls -lart ${file} ${file/$ext/avi} ${file/$ext/srt}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment