I found this old lisp. I did not write it but it works perfect. Hope it is some help
;At the command line, type (load "c:/lispdir/RENLYR")
;where c:/ is the drive where RENLYR.lsp is contained
;where lispdir/ is the directory where RENLYR.lsp is contained
(Defun C:RENLYR (/ e e-inf e-lyr txtlist sstxt sse see-inf sse-txt)
(prompt "\n")
(princ)
(while (= (setq e (car (entsel "\rSelect entity of layer to rename: "))) nil))
(setq
e-inf (entget e)
e-lyr (cdr (assoc 8 e-inf))
)
(if (/= e-lyr "0")
(progn
(setq txtlist (list (cons 0 "TEXT") (cons 1 e-lyr) (cons 10 (getvar "viewctr")) (cons 40 0.000001) (cons 50 0.0)))
(entmake txtlist)
(setq sstxt (entlast))
(command "ddedit" sstxt "")
(setq
sse (entlast)
sse-inf (entget sse)
sse-txt (cdr (assoc 1 sse-inf))
)
(if (and (/= (strcase sse-txt) (strcase e-lyr)) (/= sse-txt "") (= (wcmatch sse-txt "* *") nil))
(command "rename" "layer" e-lyr sse-txt)
(cond
((= (strcase sse-txt) (strcase e-lyr))
(prompt "\nLayer name has not been modified, name is identical")
(princ)
)
((= sse-txt "")
(prompt "\nLayer name has not been modified, nil length string")
(princ)
)
((/= (wcmatch sse-txt "* *") nil)
(prompt "\nLayer name has not been modified, name has space")
(princ)
)
)
)
(command "erase" sstxt "")
)
(progn
(if (= e-lyr "0")
(progn
(prompt "\nCannot rename layer 0")
(princ)
)
)
)
)
(princ)
)