2

I'm struggling with a srt file. I've got a very very long subtitle file and I'd like to automatically get caption text just on a single line instead of two (or worst) three different lines like in the original file. I tried many solution decide to use BBEdit and, trough Grep Find Option, find a solution to my problem, but, as I said, I'm bogged down!

Here I present you a brief example of my problem:

Original

1
00:00:00,600 --> 00:00:03,760
Block 1 - line one
Block 1 - line one

2
00:00:03,960 --> 00:00:07,120
Block 2 - line one
Block 2 - line two
Block 2 - line three

What I want:

1
00:00:00,600 --> 00:00:03,760
Block 1 - line one Block 1 - line one

2
00:00:03,960 --> 00:00:07,120
Block 2 - line 1 Block 2 - line two Block 2 - line three

Actually if you figure out a solution with different program I'll be happy as well!

Thanks in advance!

marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
PULASTER
  • 21
  • 2

1 Answers1

0
$ gawk '
>     /Block/ { block = block sep $0; sep = " " }
>     !/Block/ { if (block != "") {
>                    print block
>                    block = sep = "" }
>                print $0 }
>     END { if (block != "") print block }
> ' << EOF
> 1
> 00:00:00,600 --> 00:00:03,760
> Block 1 - line one
> Block 1 - line one
>
> 2
> 00:00:03,960 --> 00:00:07,120
> Block 2 - line one
> Block 2 - line two
> Block 2 - line three
> EOF
1
00:00:00,600 --> 00:00:03,760
Block 1 - line one Block 1 - line one

2
00:00:03,960 --> 00:00:07,120
Block 2 - line one Block 2 - line two Block 2 - line three
user448810
  • 16,364
  • 2
  • 31
  • 53