Skip to content

Instantly share code, notes, and snippets.

View CrashLaker's full-sized avatar
💭
🌌 Wired

Carlos Aguni • 顾宁 CrashLaker

💭
🌌 Wired
View GitHub Profile
@CrashLaker
CrashLaker / vtt2srt
Last active February 15, 2017 00:49
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