mkdir(path, [mode])

Make a new directory with name path and permissions mode. mode defaults to 0o777, modified by the current file creation mask.


  1. Create a directory with default permissions:

    julia> mkdir("new_directory")

    This example creates a new directory named "new_directory" in the current working directory with default permissions (0o777).

  2. Create a directory with specific permissions:

    julia> mkdir("new_directory", 0o755)

    This example creates a new directory named "new_directory" in the current working directory with permissions set to 0o755.

  3. Create nested directories:

    julia> mkdir("path/to/nested/directory")

    This example creates a nested directory structure. It creates directories "path", "to", "nested", and "directory" in the current working directory.

  4. Create a directory with an absolute path:
    julia> mkdir("/absolute/path/to/directory")

    This example creates a directory with an absolute path. It creates directories "absolute", "path", "to", and "directory" in the root directory.

Common mistake example:

julia> mkdir("existing_directory")
ERROR: mkdir: file exists (EEXIST)

In this example, the directory "existing_directory" already exists. Make sure to provide a unique name or check if the directory exists before calling mkdir to avoid this error.

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: