[Home]Srtinterpolate

Showing revision 6
Difference (from revision 6 to revision 6) (minor diff)
(The revisions are identical or unavailable.)
Renumber .srt files to add new lines, and validate the timing intervals.

Work in progress!! It already does what it claims to do, but I have feature enhancements in the works.

 #!/bin/sh
 ##
 ## Accepts a single argument, the name of the input srt file
 ## with added elements ordinated using NNN. It will also handle
 ## inserted lines with numbered ordinators, since it basically
 ## ignores the ordinator field and just builds a new ordinal
 ## sequence from scratch.
 ##
 ## Will emit a file named $input.out with properly numbered
 ## lines.
 ##
 ## The next line tells sh to execute the script using tclsh \
 exec tclsh "$0" ${1+"$@"}

 set file  [ lindex $argv 0 ]

 set fid [ open $file r ]
 set data [ read $fid [ file size $file ] ]
 close $fid
 set fid [ open $file.out w ]

 set N 1
 set last [ list ]

 foreach line [ split $data "\n" ] {
   if { [ regexp {^$} $last ] && [ regexp {^[N\d]+$} $line ] } {
      set line $N
      incr N
   }
   puts $fid $line
   set last $line
 }
 exit

See also Srtshifter

See also Ssa2srt


Transcode Wiki | Recent Changes | Preferences
Password required to edit | View other revisions | View current revision
Edited May 5, 2006 12:29 am by tarazed.ligo.caltech.edu (diff)
Search: