Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / newLISP 遍历目录树,清理编译目录

下面的代码将当前目录下所有子目录里面的dll, pdb, obj和lib文件全部删除。文件名clean.lsp;; remove *.lib, *.dll, *.pdb and *.obj in current folder
;; then handle sub folders
(define (clean-folder dir-path)
  (println "enter " dir-path)
  (let (fs (directory dir-path "\.dll|\.pdb|\.obj|\.lib"))
    (dolist (af fs)
   (begin
     (println (append "remove file: " af))
     (delete-file (append dir-path "\" af))
     )
   ))
  (let (files (directory dir-path {^[a-z]}))
    (begin
      (dolist (f files)
     (let (cf (append dir-path "\" f))
  (if (directory? cf)
      (clean-folder cf))))
      )))(clean-folder (real-path) )(exit)主要当心函数directory返回的虽然是当前目录的子文件,但是只有文件名,路径还要自己拼接。我就在这个地方没有注意,卡了一小时。相关阅读: 为Emacs配置newLISP开发环境 http://www.linuxidc.com/Linux/2013-01/78463.htm