• Login
Community
  • Login

Massive replace and enumerate

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 3 Posters 376 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.
  • L
    Ludwing Jonathan Guzman Bautista
    last edited by Oct 2, 2022, 9:42 PM

    any way to do this faster, just increase 1+ on each new item
    items:
    0:
    display_name: 0
    resource:
    material: COAL
    generate: true
    textures:
    - carbon/0.png
    1:
    display_name: 1
    resource:
    material: COAL
    generate: true
    textures:
    - carbon/1.png
    namespace: materiales
    2:
    display_name: 2
    resource:
    material: COAL
    generate: true
    textures:
    - carbon/3.png
    3:
    display_name: 3
    resource:
    material: COAL
    generate: true
    textures:
    - carbon/3.png
    4:
    display_name: 4
    resource:
    material: COAL
    generate: true
    textures:
    - carbon/4.png
    …

    T P 2 Replies Last reply Oct 2, 2022, 10:15 PM Reply Quote 0
    • T
      Terry R @Ludwing Jonathan Guzman Bautista
      last edited by Oct 2, 2022, 10:15 PM

      @Ludwing-Jonathan-Guzman-Bautista said in Massive replace and enumerate:

      any way to do this faster, just increase 1+ on each new item

      Unfortunately there is not a magic function which will do it in 1 step. There are a number of methods to doing it which will be faster than manually, but they do take some time to set up and complete.

      Method 1:

      1. Apply a delimiter to the start of every line, and then insert an incrementing number. this means each line will be associated with a line number (in order to maintain sequence). These 2 steps are completed using “Column editor”.
      2. Mark the first line (in each record) using the “bookmark line” feature so they can be cut and inserted into another tab.
      3. Again using the column editor apply an increasing number to each line, this will be the new number assignment.
      4. Replace the existing number with the new number, probably using regular expressions, although it might be possible to directly replace since the position on each line is directly in line with others. More on that if this method used.
      5. Copy the lines back to the original tab and re-sort so the altered line is re-inserted back into original position.
      6. Remove the leading number and delimiter. Finished!

      Method 2:

      1. Replace each line end with a special delimter. This will bring together each “record” (from #: until last line before the next #:) to one line only.
      2. Apply the new line numbering using column editor to all lines.
      3. Using regular expressions replace existing number with new number, and in the process removing the additional number at the start of the line.
      4. Replace the delimiter in step #1 with the normal line ending (carriage return/line feed). Finished!

      Method 2 does appear to be quicker, although the process of setting up either would take about the same amount of time. These methods would work best when you have hundreds of records to change. I’d say anything below about 50, it might be faster to just manually adjust. Of course if this is required repeating on a regular basis then mechanisation (automation) is key. The ultimate would be to setup a Python Script program, but as that is more specialised, and not many forum members use (or can program in it) you might be waiting a while. There might be a Python Script program already posted on this forum which you could adjust, but you will need to search for it yourself.

      Terry

      1 Reply Last reply Reply Quote 2
      • P
        PeterJones @Ludwing Jonathan Guzman Bautista
        last edited by Oct 2, 2022, 10:59 PM

        @Ludwing-Jonathan-Guzman-Bautista said in Massive replace and enumerate:

        any way to do this faster, just increase 1+ on each new item

        Or, if you are willing to use a plugin and have a tiny bit of coding skill, we have a FAQ on doing mathematical replacements (which includes “add one”)

        1 Reply Last reply Reply Quote 2
        3 out of 3
        • First post
          3/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors