Community
    • Login

    Need numbers going up on every blank line followed by a previous line break for subtitles

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 799 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Clayton LewisC Offline
      Clayton Lewis
      last edited by

      (Before)

      00:03:26,487 --> 00:03:28,448
      Do you mind the radio?

      00:03:29,198 --> 00:03:30,717
      Do you want me to turn the radio off?

      00:19:07,990 --> 00:19:10,367
      Okay. Be a good girl.
      Get out and go home.

      (After)

      1
      00:03:26,487 --> 00:03:28,448
      Do you mind the radio?

      2
      00:03:29,198 --> 00:03:30,717
      Do you want me to turn the radio off?

      3
      00:19:07,990 --> 00:19:10,367
      Okay. Be a good girl.
      Get out and go home.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @Clayton Lewis
        last edited by

        @Clayton-Lewis ,

        search/replace doesn’t have a way of counting, so it’s more complicated than some questions.

        If you have the PythonScript plugin, you could write a script that would do it.

        However, if you are willing to do a multi-step process, what I might suggest is:

        1. Search/Replace: FIND = \R(?!\d{2}:\d{2}:\d{2}) REPLACE = ☺ SEARCH MODE = regular expression, REPLACE ALL => this will turn your data into
          00:03:26,487 --> 00:03:28,448☺Do you mind the radio?☺
          00:03:29,198 --> 00:03:30,717☺Do you want me to turn the radio off?☺
          00:19:07,990 --> 00:19:10,367☺Okay. Be a good girl.☺Get out and go home.☺
          ...
          
        2. Insert a smiley at the beginning of each line: FIND = ^ REPLACE = ☺ SEARCH MODE = regular expression, REPLACE ALL
        3. Use Column Select mode to select the zero-width first column. The standard way of doing a column select is Alt + Click-and-drag… but if your file is long (and I assume it is), you will want an alternate:this post describes a way to accomplish it:
          1. Click in the upper-left corner of the modified document
          2. Edit > Begin/End Select
          3. Ctrl+End to get to the end of the document
          4. Alt+leftClick to the left of the first character on the last line
          5. You should now have a column selection to the left of the first column of data: 661d1cc6-cd33-425a-8529-8df6e70be91a-image.png
        4. ⦿ Edit > Column Editor
          1. Number to Insert
          2. Initial Number: 1
          3. Increase By: 1
        5. Convert the smilies back to newlines: FIND = ☺ REPLACE = \r\n SEARCH MODE = regular expression, REPLACE ALL => 9d9ba985-d000-44d6-a3ad-4ad64fd93f2e-image.png

        Hope this helps

        -–
        PS: If you find yourself often wanting to be able to do the begin/end selection in column mode, you can make a macro following instructions in this linked post

        1 Reply Last reply Reply Quote 4
        • Clayton LewisC Offline
          Clayton Lewis
          last edited by

          @PeterJones said in Need numbers going up on every blank line followed by a previous line break for subtitles:

          ⦿ Edit > Column Editor

          Number to Insert
          Initial Number: 1
          Increase By: 1

          Convert the smilies back to newlines: FIND = ☺ REPLACE = \r\n SEARCH MODE = regular expression, REPLACE ALL =>

          Awesome, thank you very much! worked like a charm except for step 3 part 2-4.
          Scrolling down to the last line before the first character then holding Shift + Alt did the trick.

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP Offline
            PeterJones @Clayton Lewis
            last edited by

            @Clayton-Lewis said in Need numbers going up on every blank line followed by a previous line break for subtitles:

            except for step 3 part 2-4.

            You are right. After 3.4, I should have said another Begin/End Selection. Sorry. But yes, what you described is equivalent.

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors