LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-28-2013, 01:57 PM   #1
Roben
LQ Newbie
 
Registered: May 2013
Posts: 6

Rep: Reputation: Disabled
Question 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.

Last edited by Roben; 06-28-2013 at 04:07 PM.
 
Old 06-28-2013, 02:05 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Try this:
Code:
$ dos2unix subtitles.srt
$ sed -r '/^[0-9]+$/{N;d}' subtitles.srt > outfile
 
Old 08-16-2021, 02:53 PM   #3
athanatic
LQ Newbie
 
Registered: Aug 2021
Posts: 1

Rep: Reputation: Disabled
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.
 
Old 08-18-2021, 06:14 PM   #4
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,790

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
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

Last edited by MadeInGermany; 08-20-2021 at 03:23 AM.
 
  


Reply

Tags
bash, subtitle



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Plain text subtitle converter script OutsiderFilms Linux - Newbie 1 11-16-2012 03:13 AM
[SOLVED] Removing line terminators from a plain text file. stf92 Linux - Software 11 07-31-2010 07:05 AM
Run commands found in plain text file splunk Linux - Software 6 02-02-2008 11:15 AM
.ram file shows as text/plain biosnacky Linux - Newbie 8 01-07-2007 08:21 PM
not a plain text file wazza4610 Linux - Newbie 1 11-22-2005 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration