Well, that is what this forum is great for....learning.....I have updated my code to include some comments that should help, but basically, what my code does is:
Select all instances of blocks that match my criteria (in this case has the words bei, detail and box in the name)
Loop through each one and insert a new block, matching all dynamic properties, attributes and the layer
Erase the old block
I do strongly recommend learning one of the programming languages, LISP is what I deal in mostly and it is extremely powerful.