• Login
Community
  • Login

Does this plugin exist? number manipulation

Scheduled Pinned Locked Moved General Discussion
6 Posts 4 Posters 250 Views
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.
  • N
    nick klaus
    last edited by Nov 16, 2024, 3:54 PM

    Hi, pretty basic np++ user here, I know a little to get by, (alt+c, ctrl+j, a bit of regex)

    I’m looking for a combination of a bit of Ctrl+h, a bit of regex and a bit of maths.

    Stating the problem clearly, I get .cue files from recording dj mixes, human readable. The cue standard uses minutes as the largest measure of time (so 1 hour 20 minute mix will be indicated with 80:00:00) a throwback to when .cue was all about audio cds limited to 74 minutes I guess)

    It seems nobody else can deal with timestamps so wildly complicated.
    I was hoping there’d be some kind of plugin that I could ctrl+f " (\d+):"
    then replace with " \1 DIV 60:\1 MOD 60:".

    Nothing I can’t do if I fire up visual studio, but I guess somebody must have some sort of base manipulator plugin.

    Any pointers please?

    Oh one more thing before I go, thing I would like from alt+c
    repeat 2 will return something like this
    1
    1
    2
    2
    3
    3
    4
    4
    5
    5

    But often I would like cycle 5
    so I get output like this
    1
    2
    3
    4
    5
    1
    2
    3
    …

    has anybody made that?
    All the best, n.k

    A T C 3 Replies Last reply Nov 16, 2024, 4:16 PM Reply Quote 1
    • A
      Alan Kilborn @nick klaus
      last edited by Alan Kilborn Nov 16, 2024, 4:17 PM Nov 16, 2024, 4:16 PM

      @nick-klaus said in Does this plugin exist? number manipulation:

      Stating the problem clearly, I get .cue files from recording dj mixes, human readable. The cue standard uses minutes as the largest measure of time (so 1 hour 20 minute mix will be indicated with 80:00:00) a throwback to when .cue was all about audio cds limited to 74 minutes I guess)

      It seems nobody else can deal with timestamps so wildly complicated.
      I was hoping there’d be some kind of plugin that I could ctrl+f " (\d+):"
      then replace with " \1 DIV 60:\1 MOD 60:".

      I’m not sure how clear this is to others, although it seems very clear to you.

      Are you saying you want to convert 80:00:00 to 1:20:00:00 (not sure what the final :00 is for?), then why didn’t you just state that explicitly as an example?

      Regardless of the exact circumstances, you can’t do this with regular Notepad++, but you can script it, or I believe the Columns++ plugin can do some math for you.


      But often I would like cycle 5
      so I get output like this

      1
      2
      3
      4
      5
      1
      2
      3
      …

      I’d say generate your first cycle, the select it, then use Duplicate selection aka Ctrl+d one or more times as needed.

      1 Reply Last reply Reply Quote 1
      • T
        Thomas Knoefel @nick klaus
        last edited by Thomas Knoefel Nov 16, 2024, 6:01 PM Nov 16, 2024, 5:30 PM

        @nick-klaus

        I’m not sure if this exactly meets your requirements, but you can give it a try with the MultiReplace Plugin . It successfully converted 80:00:00 into 1:20:00:00 for me.

        Find what: (\d+):(\d+):(\d+)
        Replace with: set( string.format("%d:%02d:%02d:%02d", math.floor(CAP1 / 60), CAP1 % 60, CAP2, CAP3) )

        Enable Options:

        • Use Variables
        • Regular expression
        1 Reply Last reply Reply Quote 4
        • C
          Coises @nick klaus
          last edited by Coises Nov 16, 2024, 6:00 PM Nov 16, 2024, 5:56 PM

          @nick-klaus said in Does this plugin exist? number manipulation:

          I was hoping there’d be some kind of plugin that I could ctrl+f " (\d+):"
          then replace with " \1 DIV 60:\1 MOD 60:".

          Columns++ can do that. You can install it from Plugins Admin. While it has features to deal with times, for the example you describe it would be easier to use the Search and Replace feature with Formulas .

          (The specific reason is that Columns++ uses colons to separate days, hours, minutes and seconds, but decimal seconds must use a decimal separator rather than a colon. For this problem, changing the last colon to a period and then back again would be more trouble than just using search/replace with a formula.)

          For your case, you would open the Plugins | Columns++ | Search… dialog and enter:

          Find what : \b(?<!:)(\d\d)(:\d\d:\d\d)\b(?!:)
          Replace with : (?=floor(reg(1)/60)):(?=2:reg(1)%60)\2
          Search Mode: Regular expression

          and either click Replace All or use Replace repeatedly.

          1 Reply Last reply Reply Quote 5
          • N
            nick klaus
            last edited by Nov 16, 2024, 11:48 PM

            Thanks to all for the information, I will look over everything recommended.

            1 Reply Last reply Reply Quote 0
            • N
              nick klaus
              last edited by nick klaus Nov 17, 2024, 1:12 AM Nov 17, 2024, 1:05 AM

              Yeah MultiReplace worked out, thanks all, if I had the rep upvotes all round.
              Just to clear up one thing the .cue standard doesn’t use 1/100th of seconds, it uses frames (75 frames = 1s) that’s why the last 2 digits has a : as a separator (another CD era throwback)

              For the record
              .cue file to modern youtube style time stamps in one pass

              MultiReplaceList.CSV

              Selected,Find,Replace,WholeWord,MatchCase,UseVariables,Regex,Extended
              1,"([\\r\\n]{0,1})\\s*TRACK \\d+ AUDIO\\r\\n\\s{4}TITLE ""(.+)""\\r\\n\\s{4}PERFORMER ""(.+)""\\r\\n\\s{4}INDEX \\d+ (\\d+:\\d+):\\d+","\\1**\\4 - \\3 - \\2**",0,0,0,0,1
              1,"\\*\\*(\\d+)","set( string.format(""**%02d:%02d"", math.floor(CAP1 / 60), CAP1 % 60) )",0,0,1,0,1
              
              

              Input

              TRACK 01 AUDIO
                  TITLE "Tragedy Blows on the Dancefloor (Kesha, Sophie Ellis-Bextor, Cutting Crew vs. Bee Gees)"
                  PERFORMER "Titus Jones"
                  INDEX 01 00:00:00
                TRACK 02 AUDIO
                  TITLE "Call My Name"
                  PERFORMER "BLOND:ISH"
                  INDEX 01 61:41:00
                TRACK 03 AUDIO
                  TITLE "HIPS DON`T LIE / SMACK YO (Charlie Roennez Mashup)"
                  PERFORMER "Shakira"
                  INDEX 01 122:49:00
              

              Output

              **00:00:00 - Titus Jones - Tragedy Blows on the Dancefloor (Kesha, Sophie Ellis-Bextor, Cutting Crew vs. Bee Gees)**
              **01:01:41 - BLOND:ISH - Call My Name**
              **02:02:49 - Shakira - HIPS DON`T LIE / SMACK YO (Charlie Roennez Mashup)**
              
              1 Reply Last reply Reply Quote 4
              6 out of 6
              • First post
                6/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors