(define-module (org helpers) #:autoload (ice-9 match) (list-pictures list-files-by-ext) #:use-module (ice-9 regex) #:use-module (ice-9 ftw) #:use-module (ice-9 match) #:use-module (srfi srfi-19) ; string/date #:export (list-pictures list-files-by-ext date->path ; do not export later *path-format*)) ;; Customize this! (setq! *path-format* ...) (define *path-format* "~Y/~m/") ;; use lowercase extensions! (define picture-exts '("png" "jpg")) (define (join-exts exts) (string-join exts "|")) (define (make-ext-regex exts) (string-concatenate `("\\." "(" ,(join-exts exts) ")" "$")) ) (define (list-files-by-ext folder exts) (scandir folder (lambda (x) (string-match (make-ext-regex exts) (string-downcase x))))) (define (list-pictures dir) (map (lambda (x) (string-concatenate `(,dir "/" ,x))) (list-files-by-ext dir picture-exts))) (define (date->path date) "Create a path structure based on the filename. Customize this with the variable *path-format*" (date->string (current-date) *path-format*))