(defun matching-files (dir regex) (when dir (let ((files (print (uiop:directory-files dir)))) (mapcar (lambda (filename) (ppcre:scan-to-strings regex (namestring filename))) files)))) (defun get-user-photo-by-etri (etri) (let* ((photo-dir (rel-path (format nil "static/img/user/~A/" (gethash :etri *session*)))) (photo (first (matching-files photo-dir ".*\.([Jj][Pp][Ee]?[Gg]|[Pp][Nn][Gg]|[Ww][Ee][Bb][Pp])")))) (and photo (format nil "/img/user/~A/photo-~A.~A" etri etri (pathname-type photo)))))