How do I get a list of files (*.jpg) from all folders, using Script-FU in GIMP?
(let* ((filelist (cadr (file-glob pattern 1)))
This only gets files from the current folder.
It will be a bit complicated, but it can be done. The list of files which file-glob returns for the current directory includes subdirectories. So you can use that list to recursively build more glob strings, which can be passed to file-glob, and so on.
(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)))))
This works, but it is slow. Perhaps you can find a way to make it faster?
By the way, this returns all files, not just JPGs. To make it return only JPGs, modify the line which says "(append files (search-dirs files))". Rather than appending "files", filter out the JPGs and append those only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With