Function: file-name-sans-extension
file-name-sans-extension is a byte-compiled function defined in
files.el.gz.
Signature
(file-name-sans-extension FILENAME)
Documentation
Return FILENAME sans final "extension".
The extension, in a file name, is the part that begins with the last .,
except that a leading . of the file name, if there is one, doesn't count.
Other relevant functions are documented in the file-name group.
Probably introduced at or before Emacs version 19.29.
Shortdoc
;; file-name
(file-name-sans-extension "/tmp/foo.txt")
=> "/tmp/foo"
Aliases
Source Code
;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun file-name-sans-extension (filename)
"Return FILENAME sans final \"extension\".
The extension, in a file name, is the part that begins with the last `.',
except that a leading `.' of the file name, if there is one, doesn't count."
(save-match-data
(let ((file (file-name-sans-versions (file-name-nondirectory filename)))
directory)
(if (and (string-match "\\.[^.]*\\'" file)
(not (eq 0 (match-beginning 0))))
(if (setq directory (file-name-directory filename))
;; Don't use expand-file-name here; if DIRECTORY is relative,
;; we don't want to expand it.
(concat directory (substring file 0 (match-beginning 0)))
(substring file 0 (match-beginning 0)))
filename))))