为了将我的.mun文件拷贝到指定文件夹下面,我写了如下程序,用点用处,但作用不太
- ;;(vlax-invoke-method (vlax-create-object "Scripting.FileSystemObject") "GetFolder" (getenv "public"))
- ;;返回存在的文件夹路径
- (defun DIRECTORY-P (str / A FLAG L STR1);(setq str (strcat (getenv "public") "/b/"))
- (setq str1 (fnsplitl str))
- (cond ((and str1 (/= (last str1) ""))
- (setq str (vl-string-right-trim "/\\" (car str1)))
- ) ;(setq str "C:\\Users\\Public\\b/1.txt")
- ((= (last str1) "") (setq str str))
- ;;(setq str "C:\\Users\\Public\\b")
- (T (setq str (vl-string-right-trim "/\\" str)))
- ;(setq str "C:\\Users\\Public\\b\\")
- )
- (if (VL-FILE-DIRECTORY-P str)
- str
- (progn
- (setq L (parse4 str "/\\"))
- (setq str1 (car L))
- (setq L (cdr L))
- (while (and (setq a (car L))
- (not Flag)
- )
- (setq L (cdr L))
- (if (VL-FILE-DIRECTORY-P (strcat str1 "\\" a))
- (setq str1 (strcat str1 "\\" a))
- (setq Flag T)
- )
- )
- str1
- )
- )
- )
- ;;(DIRECTORY-P (strcat (getenv "public") "/b/d.txt"))
- ;;(DIRECTORY-P (strcat "D:/" "块包围盒.lsp"))
- ;;(DIRECTORY-P (strcat (getenv "public") "/b"))
- ;;返回存在的文件夹路径,如果文件夹不存在,则创建
- ;;如果str是文件全路径,则保证路径所在文件夹存在
- ;;例如(VL-FILE-COPY "D:\\1.txt" "C:\\Users\\Public\\b/c/.txt"),如果没有文件夹b 和c 则创建;
- ;;以确保拷贝成功
- (defun DIRECTORYMake-P (str / A L STR1)
- (setq str1 (fnsplitl str))
- (cond ((and str1 (/= (last str1) ""))
- (setq str (vl-string-right-trim "/\\" (car str1)))
- ) ;(setq str "C:\\Users\\Public\\b/1.txt")
- ((= (last str1) "") (setq str str))
- ;;(setq str "C:\\Users\\Public\\b")
- (T (setq str (vl-string-right-trim "/\\" str)))
- ;(setq str "C:\\Users\\Public\\b\\")
- )
- (if (VL-FILE-DIRECTORY-P str)
- str
- (progn
- (setq L (parse4 str "/\\"))
- (setq str1 (car L))
- (setq L (cdr L))
- (while (setq a (car L))
- (setq L (cdr L))
- (setq str1 (strcat str1 "\\" a))
- (if (not (VL-FILE-DIRECTORY-P str1))
- (vl-mkdir str1)
- )
- )
- str1
- )
- )
- )
- ;;(DIRECTORYMake-P "C:\\Users\\Public\\b/c")
|