WLJS LogoWLJS Notebook

DirectoryName

DirectoryName["name"] extracts the directory name from the specification for a file.

Examples

Get directory from file path:

DirectoryName["/path/to/file.txt"]
(* "/path/to/" *)

Multiple levels:

DirectoryName["/a/b/c/d.txt", 2]
(* "/a/b/" *)

Please visit the official Wolfram Language Reference for more details.

On this page