Tuesday, July 8, 2008

Extracting the subtitles from a srt file using Vim

Here is a sample snippet from a srt file(subtitles for Himalaya)

1
00:02:35,600 --> 00:02:37,900
Grandfather.

2
00:02:40,800 --> 00:02:44,500
This is for my family.

3
00:02:44,500 --> 00:02:47,600
An excellent harvest, Tsering.

4
00:02:49,200 --> 00:02:55,900
How long do you think it
will feed us?

5
00:02:55,900 --> 00:02:58,600
A very long time.

Now, I want to remove the numbers 1,2,3,4,5 etc. as well as the time
information using vim.
It's damn easy.
Step 1 :
:g/-->/d (remove all the lines matching -->)
Step 2:
:g/^\s*$/d (remove all the lines containing only white spaces)
Step 3:
:g/^[0-9]\s*$/d (remove all the lines containing only numbers - this might
delete some useful stuff too, but anyway).

that's it.

No comments:

Blog Archive