Created
November 20, 2014 15:01
-
-
Save emptyset/551f82819c339fc6f0db to your computer and use it in GitHub Desktop.
Short (very rough) sketch of parsing out subtitles and applying them to a different SRT file. Not verified to work (for whatever [shell programming] reason(s), I couldn't run this all as one script, and instead had to echo out the grep commands and run the apply portion in a separate script. That could have been due to haste and not really payin…
This file contains hidden or 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 | |
# separate times and words (grep and -v) | |
grep '^[0-9]+:[0-9]+:' $1 &> $1.times | |
grep '^[0-9]+:[0-9]+:' -v $2 &> $2.words | |
# apply the times to the text | |
awk 'NR==FNR{a[i++]=$0;next;}{ if ($0 ~ /[0-9]+/) printf"%s\n%s\n", $0,a[j++];else print;}' i=1 j=1 $1.times $2.words &> $1_vs_$2.srt | |
# add the counter | |
#awk '/[0-9]+\:/{printf("%d\n%s",++counter,$0);}{print $0;}' $1_vs_$2.srt &> $1_vs_$2-final.srt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment