I've seen how to check if a file exists (file-exists-p
), but how to check if a directory exists?
Asked
Active
Viewed 8,436 times
22

Drew
- 75,699
- 9
- 109
- 225

ideasman42
- 8,375
- 1
- 28
- 105
2 Answers
36
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.

JeanPierre
- 7,323
- 1
- 18
- 37
15
file-directory-p
is your friend.
Found using C-u C-h a directory RET
and browsing the result.

Harald Hanche-Olsen
- 2,401
- 12
- 15
-
@Drew Thanks, but I had copied the key sequence wrong. Fixed now. – Harald Hanche-Olsen Jul 25 '17 at 20:10