isdir(path) -> Bool

Returns true if path is a directory, false otherwise.


  1. Check if a path is a directory:

    julia> isdir("/path/to/directory")

    This example checks if the given path is a directory and returns true if it is.

  2. Handle non-existent paths:

    julia> isdir("/nonexistent/directory")

    The function returns false for paths that do not exist on the filesystem.

  3. Use relative paths:
    julia> isdir("relative/path/to/directory")

    Relative paths can also be used with isdir to check if a directory exists relative to the current working directory.

Common mistake example:

julia> isdir("/path/to/file.txt")
ERROR: MethodError: no method matching isdir(::String)

In this example, the isdir function is mistakenly used to check if a file exists. Remember that isdir specifically checks for directories, not files. To check if a file exists, use the isfile function instead.

See Also

abspath, basename, chmod, countlines, cp, ctime, dirname, download, evalfile, expanduser, fdio, filemode, filesize, functionloc, gperm, homedir, include_string, isabspath, isblockdev, ischardev, isdir, isdirpath, isexecutable, isfifo, isfile, islink, ismount, ispath, isreadable, issetgid, issetuid, issticky, iswritable, joinpath, less, lstat, mkdir, mkpath, mktemp, mktempdir, mtime, mv, normpath, operm, poll_fd, poll_file, readall, readcsv, readdir, readdlm, readlines, readlink, realpath, relpath, rm, splitdir, splitdrive, splitext, stat, symlink, tempdir, tempname, touch, truncate, uperm, watch_file, writecsv,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: