下面的代码将当前目录下所有子目录里面的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返回的虽然是当前目录的子文件,但是只有文件名,路径还要自己拼接。我就在这个地方没有注意,卡了一小时。

 

 

 

相关文章:

  • 2022-12-23
  • 2022-01-09
  • 2021-12-03
  • 2021-10-31
  • 2021-08-16
  • 2021-10-21
  • 2022-01-22
  • 2021-08-26
猜你喜欢
  • 2021-11-22
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2021-08-10
  • 2021-06-15
相关资源
相似解决方案