vl-directory-files to make a list of only folders starting with numbers

vl-directory-files to make a list of only folders starting with numbers

mroflam
Contributor Contributor
452 Views
2 Replies
Message 1 of 3

vl-directory-files to make a list of only folders starting with numbers

mroflam
Contributor
Contributor

Im using the following code to create a list of folders under the project drive and save that list as a txt file. It works great, but I want to filter the results to be only folders that start with a 5 digit number. I have been reading about vl-directory-files all over the place but cant seem to find a filter example that does anything like what I want. In fact nearly all examples seem to be the same from site to site. 

 


(setq ListB (vl-directory-files "m:/" nil -1))

(setq fName "N:\\joblist.txt")
(setq f (open fName "w"))
(write-line (vl-prin1-to-string (acad_strlsort ListB)) f)
(close f)

 

Thank you for your help in advance! 

0 Likes
Accepted solutions (1)
453 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

That probably can't be filtered out directly, so use your own function.

 

(vl-remove-if-not '(lambda (x) (wcmatch x "#####*")) listb)

Message 3 of 3

mroflam
Contributor
Contributor

When incorporated into my previous code as such below that worked like a charm. Thank you so much!

 

 

(setq ListB (vl-remove-if-not '(lambda (x) (wcmatch x "#####*")) (vl-directory-files "m:/" nil -1)))

(setq fName "N:\\joblist.txt")
(setq f (open fName "w"))
(write-line (vl-prin1-to-string (acad_strlsort ListB)) f)
(close f)

0 Likes