Massive replace and enumerate
-
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
… -
@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:
- 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”.
- Mark the first line (in each record) using the “bookmark line” feature so they can be cut and inserted into another tab.
- Again using the column editor apply an increasing number to each line, this will be the new number assignment.
- 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.
- Copy the lines back to the original tab and re-sort so the altered line is re-inserted back into original position.
- Remove the leading number and delimiter. Finished!
Method 2:
- 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.
- Apply the new line numbering using column editor to all lines.
- Using regular expressions replace existing number with new number, and in the process removing the additional number at the start of the line.
- 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
-
@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”)