How to get a list of files (*. Jpg) from all folders?

How to get a list of files (* .jpg) from all folders using Script-FU in GIMP?

(let* ((filelist (cadr (file-glob pattern 1))) 

It only gets files from the current folder.

+7
source share
1 answer

It will be a little difficult, but it can be done. The list of files that the globule file returns for the current directory includes subdirectories. Thus, you can use this list to recursively create more global chains that can be transferred to a globe file, etc.

 (define separator "\\") ; I am using Windows (define (all-files dir) (let* ((patt (string-append dir separator "*")) (files (cadr (file-glob patt 1)))) (append files (search-dirs files)))) (define (search-dirs dirs) (if (null? dirs) (list) (append (all-files (head dirs)) (search-dirs (tail dirs))))) 

It works, but it is slow. Perhaps you can find a way to do this faster?

By the way, this returns all files, not just JPGs. To make it return only JPG, change the line that says: "(add files (search-dirs files))." Instead of adding β€œfiles”, filter the JPG and add them only.

+2
source

All Articles