I haven't tested this code but it appears to do what you are wanting to do.
Seems to me though like an easier to maintain solution would be to use an external .h file which defines an ID number and then include that in your sketch. You could then write a desktop macro to increment the number defined in the .h file before provisioning each board.