Path
path— Explore and manipulate paths.path basename— Get the final component of a path.path dirname— Get the parent directory of a path.path exists— Check whether a path exists.path expand— Try to expand a path to its absolute form.path join— Join a structured path or a list of path parts.path parse— Convert a path into structured data.path relative-to— Express a path as relative to another path.path self— Get the absolute path of the script or module containing this command at parse time.path split— Split a path into a list based on the system’s path separator.path type— Get the type of the object a path refers to (e.g., file, dir, symlink).
Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.
Tips
Intro
path parse splits a path into fields.
"/a/b.txt" | path parse
path basename keeps the file name.
"/a/b.txt" | path basename
Basic
The stem is the name without the extension.
"/a/b.txt" | path parse | get stem
path join adds one more part.
"/a/b" | path join c | path basename
Intermediate
dirname, join, and basename.
"/a/b.txt" | path dirname | path join c | path basename
Take the basename of each path.
["/a/b" "/a/c"] | each {|p| $p | path basename} | length
Advanced
Four steps from a directory to a count.
"/a/b.txt" | path dirname | path basename | str length | math abs