Or an another way with lisp.
In a new drawing copy-paste the code below directely in command line and execute the command MAKE_SCRIPT
Select a drawing in directory (any of them) to determine the folder to apply the script.
At the end, use command SCRIPT and select the "treat_folder.scr" generated by the lisp
Code:
(defun c:make_script ( / prefix file_scr)
(setq
prefix (strcat (vl-filename-directory (getfiled "Select a drawing file as WITNESS in a directory" "" "dwg" 16)) "\\")
file_scr (open (strcat prefix "treat_folder.scr") "w")
)
(foreach dwg (vl-directory-files prefix "*.dwg" 1)
(write-line "_.open" file_scr)
(write-line (strcat "\"" prefix dwg "\"") file_scr)
;;
;;start of customizable party
;;
(write-line "((lambda ( / )" file_scr)
(write-line "(foreach lay '(\"G-ANNO-TEXT\" \"M-HVAC-DUCT-IDEN\" \"M-HVAC-CDFF-IDEN\" \"A-ANNO-NOTE\" \"A-DETL\" \"G-ANNO-REVC-IDEN\" \"A-ANNO-MATC\")" file_scr)
(write-line "(if (tblobjname \"layer\" lay)" file_scr)
(write-line "(command \"_.-laydel\" \"_N\" lay \"\" \"_Y\")" file_scr)
(write-line ")" file_scr)
(write-line ")" file_scr)
(write-line "))" file_scr)
;;
;;end of customizable party
;;
(write-line "_.qsave" file_scr)
(write-line "_.close" file_scr)
)
(close file_scr)
(princ (strcat "\You can start SCRIPT :" prefix "treat_folder.scr"))
(prin1)
)
I don't test it, I hope that I not have error syntax