Skip to content

Instantly share code, notes, and snippets.

@CrashLaker
Last active February 15, 2017 00:49
Show Gist options
  • Save CrashLaker/aab98b73dbfd0b4e745a2952c0144280 to your computer and use it in GitHub Desktop.
Save CrashLaker/aab98b73dbfd0b4e745a2952c0144280 to your computer and use it in GitHub Desktop.
Bash script convert vtt subtitle to srt
#!/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