Something like this [very similar to another current topic]:
(defun C:BNU () ; = Block Name Update
(foreach item '(("Old1" "New1") ("Old2" "New2") ("OldA" "NewA") ("OldB" "NewB"))
(if
(and
(tblsearch "block" (car item)); block exists in the drawing
(not (tblsearch "block" (cadr item))); not duplicating an existing name
)
(command "_.rename" "_block" (car item) (cadr item)); then
)
)
(princ)
)
EDIT: [I just fixed a little something, so if you pulled the code very soon after originally posted, and it didn't work, try it again with the revision.]
A question: Would it be likely that any of the new Block names is already the name of a Block in the drawing? If that's possible, should the routine notify the User of any Block name(s) it was unable to change?
Kent Cooper, AIA