Ron, if the XREFs have been bound and exploded, you could try this routine:
;REMVLONG.lsp
;
;OBJECTIVE***
;The purpose of this routine is to allow the user to strip
;the lengthy portion of layer name including the "|0|" which
;result from the binding of external reference files.
;
;SPECIAL INSTRUCTIONS***
;1. Explode all Bound External Reference Files before beginning.
;2. Due to the nature of this routine, it should be understood
;that the layers are not renamed, therefore, the layer name
;remains. To remove it, you must DXFOUT your file, recreate
;the file from the DXF and then purge to rid the layers, blocks,
;and linetypes.
;
(Defun c:REMVLONG ()
(prompt "\nRoutine to remove Bound Layer Names")
(command "undo" "m")
(setq c_lyr (getvar "CLAYER"))
(COLLECT_DATA)
)
(Defun COLLECT_DATA ()
(setq lyrs (tblnext "LAYER" T))
(while (/= lyrs nil)
(setq lyr_nam (cdr (assoc 2 lyrs)))
(setq lyr_lt (cdr (assoc 6 lyrs)))
(setq lyr_clr (cdr (assoc 62 lyrs)))
(if (= (wcmatch lyr_nam "*$?$*") T)
(progn
(setq ss_dat (ssget "X" (list (cons 8 lyr_nam))))
(EVAL_LYR)
(EVAL_LT)
(if (= (tblsearch "LAYER" lyr) nil)
(progn
(if (= (wcmatch lyr_lt "*$?$*") T)
(command "layer" "m" lyr "c" lyr_clr "" "lt" lt "" "")
(command "layer" "m" lyr "c" lyr_clr "" "lt" lyr_lt "" "")
)
)
)
(if (/= ss_dat nil)
(command "change" ss_dat "" "p" "la" lyr "")
)
)
)
(setq lyrs (tblnext "LAYER"))
)
(setvar "CLAYER" c_lyr)
(if (= (substr (getvar "acadver") 1 2) "13")
(repeat 3
(command "purge" "b" )
(while (= (getvar "CMDNAMES") "PURGE")
(command "y" )
);end while
)
)
)
(Defun EVAL_LYR ()
(if (= (wcmatch lyr_nam "*$?$*") T)
(progn
(setq
nam_len (strlen lyr_nam)
cnt 1
fnd (substr lyr_nam cnt 3)
fndit (wcmatch fnd "$?$")
)
(while (/= fndit T)
(setq
cnt (+ 1 cnt)
fnd (substr lyr_nam cnt 3)
fndit (wcmatch fnd "$?$")
)
)
(setq lyr (substr lyr_nam (+ cnt 3)))
)
)
)
(Defun EVAL_LT ()
(if (= (wcmatch lyr_lt "*$?$*") T)
(progn
(setq
lt_len (strlen lyr_lt)
cnt 1
fnd (substr lyr_lt cnt 3)
fndit (wcmatch fnd "$?$")
)
(while (/= fndit T)
(setq
cnt (+ 1 cnt)
fnd (substr lyr_lt cnt 3)
fndit (wcmatch fnd "$?$")
)
)
(setq lt (substr lyr_lt (+ cnt 3)))
(setq is_lt (ssget "X" (list (cons 6 lyr_lt))))
(if (= is_lt nil)
(progn
(command "filedia" "0")
(command "linetype" "l" lt "" "" "")
(command "filedia" "1")
)
)
)
)
)
(prompt "\nCommand Name is Remvlong\n")