这应该在LISP中工作:
- (defun c:DocSuff (/ *error* *acad FOLDER FPATH SHELL SUFF)
- (vl-load-com)
- ;; Suffix Filename ~ Lee Mac
- (defun *error* (msg)
- (and Shell (not (vlax-object-released-p Shell))
- (vlax-release-object Shell))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ))
- (setq Suff (getstring t "\nSpecify Suffix: ")
- *acad (vlax-get-acad-object)
- shell (vla-getInterfaceObject *acad "Shell.Application")
- folder (vlax-invoke-method shell 'BrowseForFolder
- (vla-get-HWND *acad) "Select Directory" 0))
- (vlax-release-object shell)
-
- (if folder
- (progn
- (setq fpath (vlax-get-property
- (vlax-get-property folder 'Self) 'Path))
-
- (and (/= (substr fpath (strlen fpath)) "\")
- (setq fpath (strcat fpath "\")))
-
- (foreach dwg (mapcar
- (function
- (lambda (x) (strcat fpath x)))
- (vl-directory-files fpath "*.dwg" 1))
-
- (vl-file-rename dwg
- (strcat fpath (vl-filename-base dwg) Suff ".dwg"))))
-
- (princ "\n*Cancel*"))
-
- (princ))
将重命名目录中的所有内容。 |