(defun c:GenScr (/ dwgPath dwgList dwgName numDwgs count scrFile)
;;; Path should be like "c:\\projects\plots\\" or "c:/projects/plots/"
;;; Substitute your path here.
(setq dwgPath "C:\\test\\"
; sets the path
dwgList (vl-directory-files dwgPath "*.Dxf")
; get the list of all the dxf's
)
(if dwgList ; if dwg files exists there
(progn
(setq numDwgs (length dwgList) ; number of drawings
count 0 ; initiate counter
scrFile (open (strcat dwgPath "Runme.scr") "w")
; open a script file in the same folder
)
(repeat numDwgs ; for all the drawings
(setq dwgName (strcat "\"" dwgPath (nth count dwgList) "\""))
(write-line ".Open" scrFile) ; write to script file
(write-line dwgName scrFile)
;;;
;;; Preset the dxf file format before you proceed.
;;; May require minor modification depending on you
;;; AutoCAD version Notice the two spaces after dxfout
;;; in the following line acts like <enter>.This will
;;; accept the default file name and default format
(write-line ".wmfout " scrFile)
(write-line "ALL " scrFile)
;;; Better to save the drawing for uninterrupted scripting
;(write-line ".Qsave" scrFile)
(write-line ".close" scrFile)
(write-line "Y" scrFile)
(setq count (1+ count)) ; next dwg
)
(close scrFile) ; close when done
;;; Make sure that the current dwg won't prompt for
;;; save changes!
(command ".script" (strcat dwgPath "Runme.scr")) ; run the script
) ; progn
) ; if
(princ)
) ; defun
EDIT: oops, posted too soon