user1067455
user1067455

Reputation: 61

Macro, automatically adding one to a value

I have a problem with macro in notepad++

Just needs to have value automatically changed to +1 (from current value)

So the values should be like this 1000, 1001, 1002, 1003 and so on for the coming values between the MEDIA_ID tags..

      <MEDIA>
      <MEDIA_ID>1000</MEDIA_ID>
      </MEDIA>
      <MEDIA>
      <MEDIA_ID>1001</MEDIA_ID>
      </MEDIA>

I have no idea how do this..

Could anyone help?

Thanks

Upvotes: 6

Views: 6569

Answers (2)

Pradeep Vairamani
Pradeep Vairamani

Reputation: 4312

1) Generate the list of numbers from 1000 to the number you want using excel and copy this into notepad++.

2) Go to the start of the file.

3) Start the macro recorder.

4) type <MEDIA>(down arrow)(HOME button)<MEDIA_ID>(END button)</MEDIA>(down arrow)(HOME button)</MEDIA>(down arrow)(HOME button)

5) repeat this macro as many times as needed.

Upvotes: 6

anon
anon

Reputation:

If you can align the tags vertically then you might be able to use the Column Editor to do the numbering. Say you format the XML like this:

<MEDIA><MEDIA_ID></MEDIA_ID></MEDIA>
<MEDIA><MEDIA_ID></MEDIA_ID></MEDIA>
....
<MEDIA><MEDIA_ID></MEDIA_ID></MEDIA>

Now, place your cursor betweeen the start and end tags of MEDIA_ID. Choose Column Editor... from the Edit menu (ALT+C keyboard shortcut). Change the radio button to Number to Insert with a starting value of 1001 incrementing by 1 (Decimal). Confirm using the OK button. You should end up with this:

<MEDIA><MEDIA_ID>1001</MEDIA_ID></MEDIA>
<MEDIA><MEDIA_ID>1002</MEDIA_ID></MEDIA>
....
<MEDIA><MEDIA_ID>1199</MEDIA_ID></MEDIA>

Sadly, it seems that this operations cannot be used in a macro. But maybe it helps.

Upvotes: 4

Related Questions