RecipesEdit in bulk

How do I rename many layers at once in AutoCAD?

Type "rename every layer starting with X- to A-, keep the rest of the name". cadssistant walks the layer table, runs RENAME for each X- layer in one AutoLISP pass and replies with the list of renames (X-WALL to A-WALL and so on) and any target name that already existed. Objects stay where they are; a layer name is a label. Layers that belong to an xref can't be renamed and are reported, not changed.

Checked 2026-10-30

What you typeCommand: CADSSISTANT

rename every layer starting with X- to A-, keep the rest of the name

Paste it into the palette, or pick it from the recipes inside the chat.

What cadssistant does

  1. Reads the layer table with tblnext and matches names with wcmatch "X-*".
  2. Runs -RENAME Layer old new for each match in one AutoLISP pass; a target that already exists is skipped and reported.
  3. Replies with old → new for every layer. Xref-dependent layers (names containing |) are left alone.

The same task in AutoLISP

(progn
  (setq def (tblnext "LAYER" T) names nil done nil)
  (while def
    (if (wcmatch (cdr (assoc 2 def)) "X-*") (setq names (cons (cdr (assoc 2 def)) names)))
    (setq def (tblnext "LAYER")))
  (foreach nm names
    (if (not (tblsearch "LAYER" (strcat "A-" (substr nm 3))))
      (progn
        (command "_.-RENAME" "_LA" nm (strcat "A-" (substr nm 3)))
        (setq done (cons nm done)))))
  done)

Collects the matching names first, then renames each unless the target exists. Returns the layers it renamed.

Good to know

  • Renaming to a layer standard: paste the old-to-new mapping as a table in the message and it uses that instead of a pattern.
  • Say "merge instead" and it runs LAYMRG, which moves the objects onto the target and deletes the source, a different operation.

More in edit in bulk

Command: CADSSISTANT

Works in AutoCAD 2024 and newer on Windows. Free trial, no card, no API key.

Get cadssistant