Hmmm...
Well there are many ways that lead to Rome, but I'm not sure this is the right/easiest way.
It sounds/looks like you opened 2000 dwg's by hand or something. just the code is run automatically.
A real easy way:
(defun C:MF (/ filelist file)
; this function is my Proof of Concept (Roland.R71)
; for running lisp on multiple drawings
; (sequential, without a batch)
; for this you need:
; - A list of files to process
; - Some lisp code (or file) you wish to run on each drawing
; create list with filenames. For this example a hardcoded
; list is used, to show what the list should look like.
(setq filelist
(list "C:/Lisp/TestDWG/Test_LayoutSET1.dwg"
"C:/Lisp/TestDWG/Test_LayoutSET2.dwg"
"C:/Lisp/TestDWG/Test_LayoutSET3.dwg"
)
)
; the next part is an example to select a directory and read
; all files into a list, like the above.
; NOTE: Either use this OR the hardcoded method, not both.
; First we set the directory to read
; (setq dwgdir "c:/lisp/testDWG")
; ...but of course you don't want that directory to be hardcoded...
; sadly basic autolisp has no function to let the user select
; (just) a directory.
; If you have DOSlib, it suddenly becomes easy:
; (setq dwgdir (DOS_GETDIR "Select directory:" "c:/lisp/testDWG"))
; This will retrieve all (and only: thats what the 1 is for)
; the filenames from set directory.
; (setq filelist (vl-directory-files dwgdir "*.dwg" 1))
; activate single document mode (required for sequential
; processing, using a script or lisp)
(setvar "SDI" 1)
; Turn off the (re)intialisation of lisp with each drawing.
; Meaning: lisp functions will stay loaded.
(setvar "LISPINIT" 0)
; for each file in the list
(foreach file filelist
; Open and process it.
(command "_.fileopen" file) ; open it.
; --- Insert code to run here, or load/execute another lisp
(command "Zoom" "e") ; a simple zoom for the example
; --- end of code to run on each file
(command "Qsave") ; save it.
)
)