;;用循环法,删除指定目录下某类型文件
 - (defun GetFullPath (path)
- (if (wcmatch path "*\\")
- path
- (strcat path "\\")
- )
- )
- (defun C:a2d (/ A DIR DIRL F LST X)
- (if (not **Initdir**)
- (setq **Initdir** "D:\\")
- )
- ;;(setq LST (list (GetFolder3 "浏览文件夹" "包括子文件夹" **Initdir**)))
- (setq LST (list "D:\\0000\\"));本示例删除D:\\0000\\下所有指定类型文件文件,包括子目录
- (foreach filter '("*.dwg" "*.pdf" "*.tif" "*.jpg" "*.exb" "*.doc" "*.xlsx" "*.docx")
- (setq dirL LST)
- (while (setq dir (car dirL))
- (setq dirL (cdr dirL))
- (setq f (vl-directory-files dir filter 1))
- (setq f
- (mapcar '(lambda (x)
- (strcat (getfullpath dir) x)
- )
- f
- )
- )
- (vl-every 'vl-file-delete f) ;此句可改为处理文件
- (setq a nil)
- (setq a (vl-remove-if
- '(lambda (subdir)
- (member subdir '("." ".."))
- )
- (vl-directory-files dir nil -1)
- )
- )
- (setq a (mapcar (function (lambda (x) (strcat dir x "\\"))) a))
- (setq dirL (append dirL a))
- )
- )
- (princ)
- )
|