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.
##
## 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 Ssa2srt