Last active
February 15, 2017 00:49
-
-
Save CrashLaker/aab98b73dbfd0b4e745a2952c0144280 to your computer and use it in GitHub Desktop.
Bash script convert vtt subtitle to srt
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/bash | |
# $1 = filelocation | |
# Renames filename.vtt to filename.srt besides converting it | |
sed -i "/WEBVTT/d" $1 | |
for i in `grep -n "\-\->" $1 | cut -d: -f1`; do sed -i "${i}s/\([0-9]\)\.\([0-9]\)/\1,\2/g" $1; done | |
newname=`echo $1 | sed "s/vtt/srt/g"` | |
mv $1 $newname | |
x=1;for i in `grep -n "^$" $newname | cut -d: -f1`; do sed -i "${i}s/.*/crashlaker${x}/" $newname; x=$((x+1)); done | |
sed -i "s/crashlaker/\n/g" $newname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment