用doslib的dos_find,支持通配符。如果在搜索路径找到(当然使用通配符是不能用findfile找到的),返回第一个文件全名,否则全盘搜索,返回找到的文件全名列表。 Usage: (search "123.dwg")或(search "B*.dwg")问题:使用通配符搜索的结果和windows explorer的结果有点出入,原因不明。- (defun search (pattern / filefound)
- (dos_waitcursor t)
- (command "modemacro" "正在搜索文件,请稍候...")
- (setq filefound (findfile pattern))
- (if (not filefound)
- (foreach drv (dos_drives)
- (if (setq found (dos_find (strcat drv "\" pattern)))
- (setq filefound (append filefound found))
- )
- )
- )
- (if (listp filefound)
- (setq filefound
- (vl-remove-if '(lambda (e) (wcmatch e "*\\RECYCLER\\*"))
- filefound
- )
- )
- )
- (dos_waitcursor)
- (command "modemacro" " ")
- filefound
- )
|