Give this a try i think its what your looking for if i understood you right.
;;
;; BCONVERT.LSP
;;
;; Performs a Drawing Open, ZOOM Extents and Save on an entire Directory
;;
;; Note: This utility leaves behind 3 scratch files in the target Directory:
;;
;; Convertst.scr
;; Temp.dwg
;; Temp.txt
;;
;; These 3 scratch files may be deleted after processing is complete
;;
;; TO USE:
;; Setup target Directory on local HDD containing ONLY drawings to convert
;; Launch AutoCAD
;; Set SDI sysvar to 1
;; Type (load "bconvert.lsp")
;; Type BCD
;; Respond to prompts, navigate to target Directory and select first listed drawing
;; Processing will be automatic
;; Set SDI sysvar to 0
;; Close AutoCAD
;;
(setq *process "")
;;
;; MAIN ROUTINE
;;
(defun C:BCD (/ afile)
(alert "This routine does a zoom extents on an entire directory. Click OK to continue.")
(setq afile (getfiled (strcat "Select the first file of the directory "
"to be processed") "" "DWG" 0))
(if afile
(bprocess (strp_path afile))
(alert "You must select the first file of the directory to be processed. Conversion halted.")
)
)
;;
;; Core processing
;;
(defun bprocess(listpath / tempfile filelist scrfile fp file)
(setq tempfile (strcat listpath "temp.dwg"))
(if (findfile tempfile)
(command "_SAVE" tempfile "y")
(command "_SAVE" tempfile)
)
(setq filelist (get_file_list listpath "DWG")) ; Build list of drawings to process
(setq scrfile (strcat listpath "convertst.scr")) ; Begin building processing script
(setq fp (open scrfile "w"))
(foreach file filelist ; Add each drawing to script
(write-line (strcat "OPEN " "\"" listpath file "\"") fp) ; OPEN
(write-line (strcat "Zoom") fp) ; ZOOM...
(write-line (strcat "chprop") fp) ; ...Change Properties
(write-line (strcat "all") fp) ; ...all entities
(write-line (strcat "") fp) ; ...ENTER
(write-line (strcat "la") fp) ; ...Layer
(write-line (strcat "0") fp) ; ...0
(write-line (strcat "c") fp) ; ...Color
(write-line (strcat "BYLAYER") fp) ; ...BYALYER
(write-line (strcat "layer") fp) ; ...Layer
(write-line (strcat "s") fp) ; ...Set
(write-line (strcat "0") fp) ; ...0
(write-line (strcat "") fp) ; ...ENTER
(write-line (strcat "purge") fp) ; ...Purge
(write-line (strcat "a") fp) ; ...ALL
(write-line (strcat "") fp) ; ...ENTER
(write-line (strcat "n") fp) ; ...No
(write-line (strcat *process "_QSAVE") fp) ; SAVE
)
(close fp)
(command "_SCRIPT" scrfile) ; Run the script
(princ)
)
;;
;; Return file list in listpath directory with extention ext
;;
(defun get_file_list (listpath ext / listfile fp fileline linelen
startnum filelist scr file extention filename c)
(setq listfile "temp.txt")
(setq listfile (strcat listpath listfile))
(setq fp (open listfile "w"))
(write-line "File list for this directory:" fp)
(close fp)
(setq filelist '())
(setq scr (strcat "dir " listpath " > " listfile))
(command "_shell" scr)
(command "_delay" 2000)
(setq fp (open listfile "r"))
(while (setq fileline (read-line fp))
(setq linelen (strlen fileline))
(setq startnum 40)
(if (= (substr fileline startnum 1) ":")
(setq startnum 45)
)
(if (> linelen (+ startnum 3))
(progn
(setq file (substr fileline startnum (1+ (- linelen startnum))))
(setq extention (substr file (- (strlen file) 2) 3))
(if (= (strcase extention) (strcase ext))
(setq filelist (append filelist (list file)))
)
)
)
)
(close fp)
(setq filelist filelist)
)
;;
;; Process the drawing file name
;;
(defun strp_name (full_str / count full_count not_found)
(if full_str
(progn
(setq count (strlen full_str))
(setq full_count count)
(setq not_found T)
(while not_found
(if
(or
(= (substr full_str count 1) "\\")
(= (substr full_str count 1) "/")
)
(setq not_found nil)
(setq count (- count 1))
)
)
(substr full_str (1+ count) (- full_count 1) )
)
(eval "")
)
)
;;
;; Strip the path information from the file name
;;
(defun strp_path(fullname / path name)
(setq name (strp_name fullname))
(setq path (substr fullname 1 (- (strlen fullname) (strlen name))))
)
(princ)