rRename - regex rename utility for AutoCAD tables
(C)2024, CAD Studio (ARKANCE CZ)   https://arkance.world
---------------------------------------------------------------

rRename is a LISP utility for AutoCAD (any version), which
allows to rename blocks, layers, layouts and linetypes,
views, textstyles, dimstyles, tablestyles, materials,
viewports, user coordinate systems and groups
with simple find/replace or with regular expressions.

Unlike the standard RENAME command you can use it to batch-
rename layouts or to perform complex renaming schemes like
swapping parts of a name, inserting substrings or adding
counters (see examples).

Just load the RRENAME.VLX using APPLOAD or ACADDOC.LSP.
Start renaming by entering the RRENAME command. It prompts
for a type of object to rename:

Rename [Blocks/Layers/lineTypes/layOuts/Views/Textstyles/
Dimstyles/tAblestyles/Materials/viewPorts/Ucs/Groups] <layOuts>:

Since V1.4 you can also use Civil object tables to rename:
poIntgroups/Surfaces/Alignmentstyles/pRofilestyles/sitEs

Then enter the substring or regular expression to find and
the substring or regular expression to replace. A standard
text will just perform a search/replace renaming. The "*"
character in the search string will be used as a wildcard
(in fact as the ".+" regular expression). The "#" character
in the replace string will be used as a counter (1,2,3...).
The regular expression strings can match object names in
complex schemes. The renaming process will avoid objects like
the "Model" layout, the layer "0" or the "ByLayer" linetype.

Regular Expressions allow to specify "(.+)" as stored groups
in the search and refer them in the replace string as "$1",
"$2", etc. Read more at:
http://en.wikipedia.org/wiki/Regular_expression

Renaming examples (do not type the double-quotes):

"" (empty string) --> "X"
prefix all names with "X"

"*" --> "New#"
rename all objects to New1, New2, New3, etc.

"(.+)" --> "Pre-$1-Post"
add "Pre-" as prefix and "-Post" as suffix to all names:
Layer1 --> Pre-Layer1-Post

"(.+)-(.+)" --> "$2-$1"
swap parts of names, like "Layer-Electro" to "Electro-Layer"

"(.{3})(.+)" --> "$1-NEW-$2"
add "-NEW-" after first 3 characters:
Layer1 --> Lay-NEW-er1

"(.+)([0-9]+)" --> "$1-#-NEW"
delete trailing numbers, renumber and add "-NEW":
Layer10 --> Layer-1-NEW
Layer15 --> Layer-2-NEW

"[\x20-\x7F]/g" --> "_"
replace non-ASCII characters with "_", globally (multiple):
Žluťoučký --> _lu_ou_k_
Kůň --> K__

Since V1.7 you can also use computed replacements for numbers:
"Block([0-9]+)" --> "Block{$1+100}"
Block123 --> Block223 (or Block00223)

NB:
You can use the LISP variable RRenameMatchCase to enable
exact case match ("E" not equal to "e"):
(setq RRenameMatchCase T)

You can use the LISP variable lastRRename to preset the
object type:
(setq lastRRename "Blocks")


Version history:
1.0: first release
1.1: regex is not global
1.2: added Views/Textstyles/Dimstyles/tAblestyles/Materials/viewPorts/Ucs/Groups
1.3: name validity check, beep on error
1.4: poIntgroups/Surfaces/Alignmentstyles/pRofilestyles/sitEs
1.5: /g option (or /gi) for reg.expressions
1.6: RRenameNoCheck added for partial renames
1.7: RRenameCounter and RRenamePadTo variables
     computed $1 replacements (+-/*)


License: RRENAME is a free utility by ARKANCE,
do not publish it online on other than ARKANCE's
web servers, do not sell, lend or exchange it.

----------------------------------------------------
Contact:
Arkance Systems CZ s.r.o. (formerly known as CAD Studio)
Libalova 1, 149 00 Praha, Czech Republic
info.cz@arkance.world  www.arkance.world www.cadstudio.cz  www.cadforum.cz
