|
[code] ;自定义函数:files_of_folder 作者ygs-羊羊羊,其中提取文件夹子文件夹的子函数来自73大师
;提取指定文件夹下指定文件类型的文件列表
;执行 (files_of_folder(setq folder "D:\新建文件夹 (7)") "*.dwg" )
;参数:folder 需提取文件的文件夹完整路径,file_suffix 需提取文件的文件后缀(均为字符串)
;返回值:指定路径下得指定文件的列表
;主函数
(defun files_of_folder(folder file_suffix / WJJLB WJLB)
(setq wjlb nil)
(setq wjjlb(xdirectory folder))
(foreach x wjjlb
(setq wjlb(cons(vl-directory-files x file_suffix 1)wjlb))
)
(setq wjlb(apply 'append wjlb))
)
;以下两个子函数来自73大师
(defun xdirectory(folder);;;好象不含隐藏目录
(setq folder(list(list folder)))
(while(car(setq folder(cons(apply'append(mapcar'(lambda(x)(mapcar'(lambda(y)(strcat x"\\"y))(cddr(vl-directory-files X nil -1))))
(car folder)))folder))))(apply'append folder))
(defun SubFolers(folder / folders *Fso fold xx);;;包含隐藏目录
(defun xx(/ lst)
(vlax-for x(vlax-get-property(vlax-invoke-method *fso 'getfolder fold)'SubFolders)
(setq lst(cons(vlax-get-property x 'path)lst)))
(reverse lst))
(if(VL-FILE-DIRECTORY-P folder)
(progn
(setq *Fso(vlax-get-or-create-object"Scripting.FileSystemObject")
folders(list(vlax-get-property(vlax-invoke-method *fso 'getfolder folder)'path))i 0)
(while(setq fold(nth i folders))
(setq folders(append folders(append(xx)))i(1+ i)))
(vlax-release-object *Fso)
folders)))
[/code] |
|