I've seen how to check if a file exists (file-exists-p
), but how to check if a directory exists?
2 Answers
From elisp manual:
-- Function: file-directory-p filename
This function returns ‘t’ if FILENAME is the name of an existing directory, ‘nil’ otherwise.
See also its docstring, with a note concerning symlinks:
(file-directory-p FILENAME)
Return t if FILENAME names an existing directory. Symbolic links to directories count as directories. See ‘file-symlink-p’ to distinguish symlinks.
file-directory-p
is your friend.
Found using C-u C-h a directory RET
and browsing the result.
-
@Drew Thanks, but I had copied the key sequence wrong. Fixed now. Jul 25, 2017 at 20:10