LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How can I extract plain text from a srt file (subtitle) by eliminating the time codes? (https://www.linuxquestions.org/questions/programming-9/how-can-i-extract-plain-text-from-a-srt-file-subtitle-by-eliminating-the-time-codes-4175467742/)

Roben 06-28-2013 01:57 PM

How can I extract plain text from a srt file (subtitle) by eliminating the time codes?
 
How can I remove time codes of a ".srt" file to provide it for print? I want Order of terms in the extracted file to be the same as the original file.

druuna 06-28-2013 02:05 PM

Try this:
Code:

$ dos2unix subtitles.srt
$ sed -r '/^[0-9]+$/{N;d}' subtitles.srt > outfile


athanatic 08-16-2021 02:53 PM

Worked perfectly! Thanks!
 
I will be using that trick a fair amount. I needed to get the transcript of a rant on Lewis Black's podcast. I sent him the proofed text after and it was MUCH easier with that crap gone.

MadeInGermany 08-18-2021 06:14 PM

Also examine the following line:
Code:

sed -r 's/\r$//;/^[0-9]+$/{N;/\n[0-9]/d;}' subtitles.srt
EDIT: by deleting the WinDOS \r it does a dos2unix


All times are GMT -5. The time now is 04:29 AM.