Returns the extension of a filename. The extension is the last "."-delimited part of the name. Returns "" if there is no period in the filename.
(define (file-extension filespec)
;; Return the extension of a filename
(if (string? filespec)
(let* ((pathparts (match-split filespec "/"))
(filename (list-ref pathparts (- (length pathparts) 1)))
(fileparts (match-split filename "."))
(extension (list-ref fileparts (- (length fileparts) 1))))
(if (> (length fileparts) 1)
extension
""))
""))