• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
blog.draftsperson.net

blog.draftsperson.net

the art of technical drawing

blog.draftsperson.net

BATCHSCRIPT LISP: Run One Command on Every Drawing

August 3, 2026

Type one line of AutoCAD commands, point at a folder, and BATCHSCRIPT writes a script that repeats that line for every drawing it finds — then runs it. No drawing is opened by hand and no script file has to be written.

What BatchScript does

The line uses the token *file* wherever a drawing name belongs. So this:

_.open *file* _.saveas *file* _.close

becomes, for a folder of two hundred drawings, two hundred lines that open each one, save it in the current format and close it. That single example is the standard fix for a whole project stuck in an old DWG version.

Anything you can type at the command line can go in that line: purge a whole set, audit it, insert a revised title block, or run one of your own LISP commands across every sheet.

Saved lines are remembered. Every line you save is offered again from the Load button, so the operations you run regularly are one click away. The list, the last folder used and the sub-folder setting are written to a small configuration file and reloaded next time.

How to use it

  1. Copy the folder first. See the warning below — this is not optional advice.
  2. Load the routine with APPLOAD, or put it on your support file search path.
  3. Type BATCHSCRIPT.
  4. Type the command line, using *file* where a drawing name belongs. Or press Load to recall one you saved earlier.
  5. Choose the folder, and tick sub-folders if you want it to recurse.
  6. Accept the dialog. The script starts immediately.

How it works

The script line is split on the *file* token into fixed fragments. For every drawing found, those fragments are re-joined with the drawing’s full path substituted at each token position — in quotes, so spaces in folder names cannot break the script. The assembled lines are written to a script file and handed to the SCRIPT command.

AutoCAD executes a script line by line exactly as if it had been typed, which is why an ordinary command sequence works unaltered. There is no special syntax to learn beyond the token.

Folder scanning is recursive when the sub-folders box is ticked: each folder’s sub-folders are found and searched in turn, all the way down.

Load can also read an existing .scr file. Its first line is read and the drawing name in it turned back into a *file* token, which recovers an editable script line from a script somebody else wrote — useful when you have inherited a script and want to understand or adapt it.

Notes and limits

  • A batch script modifies drawings without opening them in front of you, and there is no undo across files. A line with a mistake in it will apply that mistake to every drawing in the folder. Test on a copy of the folder first. Every time.
  • The script starts as soon as the dialog is accepted. There is no second confirmation.
  • The current drawing is not part of the run. AutoCAD executes the script in whatever drawing you are in, so the first thing your line should normally do is open a file.
  • Check the line on one drawing before turning it loose. Point it at a folder containing a single test file first.

Download and details

NameBatchScript — run the same operation on every drawing in a folder
DownloadBatchScript.lsp — 30.8 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandBATCHSCRIPT
Requiresthe ActiveX layer (loaded automatically by the routine with vl-load-com); nothing extra — the dialog is written to a temporary file at run time and deleted again, so there is no .dcl to install.
Source size30.8 KB, 740 lines
Error handlingYes — a *error* handler restores every system variable it changed, on cancel as well as on error.
UndoThe whole operation is wrapped in a single undo group, so one U reverses all of it.
CompatibilityAutoCAD (any release with AutoLISP), BricsCAD, ZWCAD, GstarCAD, ProgeCAD and other IntelliCAD-based platforms. AutoCAD LT needs a LISP enabler. No .NET, no ObjectARX, no installer.
AuthorYZ, August 2026
LicenceFree to use, supplied “as is” with no warranty.

References

  • ATTPULL and ATTPUSH LISP — batch attribute extract and edit, without scripting
  • DWGPUSH LISP — another way to push changes across a folder
  • More free AutoLISP routines on this site
  • Wisey’s Steel Shapes — free structural steel section drawing program

Filed Under: AutoLISP Routines

Primary Sidebar

Subscribe to our Youtube Channel

Post CAD drafting jobs on Freelancer.com. and get some free money to do this.

Categories

  • American Steel Industry (4)
  • AutoCAD Articles & Reference (30)
  • AutoCAD Bugs & Problems (19)
  • AutoCAD Tips (29)
  • AutoCAD Tutorials (54)
  • AutoLISP Routines (328)
  • AutoLISP Tutorials (15)
  • CAD Standards (7)
  • Civil 3D (7)
  • Civil Drafting (4)
  • Dimensions (2)
  • Drafting Funnies (71)
  • Drafting History (9)
  • Drafting Standards (84)
  • Electrical Drafting (2)
  • General IT reference (7)
  • Geometry (15)
  • GIS (2)
  • Hatch Patterns (12)
  • Office Life Hacks (3)
  • PT (1)
  • Revit Tutorials (54)
  • Steel Detailing (14)
  • Structural Drafting (26)
  • Technical Dictionary (61)
  • Useful Website Links (19)

Footer

Free downloads

  • Free AutoLISP routines
  • Free hatch patterns
  • SHX fonts & text styles
  • Numbering LISP collection
  • ISO 3098B font

Reference charts

  • AWS weld symbols chart
  • Steel detailing chart
  • Hole & slot sizes
  • Bolt edge distance
  • ANSI & ARCH paper sizes
  • How to fold an A1 drawing

Useful links

  • CAD blocks (DWG)
  • Revit families
  • structuraldrafter.com
  • cad-corner.com
  • About
  • Privacy policy

Provided for free with no warranty · Log in