path — file names
mzs
include pathINFO
Available in bot scripts.
Everything is lexical: the module does not look at the disk, and the separator is always /.
| Function | What it does |
|---|---|
path.join(a, b, …) | join with / and clean; empty parts are skipped |
path.dir(p) | everything before the last element; "." if none |
path.base(p) | the last element |
path.ext(p) | the extension with its dot; "" for .gitignore |
path.stem(p) | the name without the extension |
path.clean(p) | removes ., .. and double / |
path.split(p) | an array of elements |
path.rel(p, base) | p relative to base; nil if it can't be expressed |
path.is_abs(p) | whether it starts with / |
path.match(pattern, name) | glob: *, ?, [a-c], ** for any folders |
Joining
"in/" + name gives in//x or inx; join doesn't.
mzs
include path
path.join("in", "report.json") # → "in/report.json"
path.join("a/", "/b", "", "c") # → "a/b/c"
path.join("in", "../out", "x.json") # → "out/x.json"Taking apart
mzs
include path
p = "data/2026/report.tar.gz"
path.dir(p) # → "data/2026"
path.base(p) # → "report.tar.gz"
path.stem(p) # → "report.tar"
path.ext(p) # → ".gz"
path.split("/usr/local/bin") # → ["/","usr","local","bin"]
path.ext(".gitignore") # → ""
path.base("a/b/") # → "b"Changing the extension:
mzs
include path
fn with_ext(p, e) { path.join(path.dir(p), path.stem(p) + e) }
with_ext("in/report.csv", ".json") # → "in/report.json"Cleaning and comparing
mzs
include path
path.clean("a//b/./c/..") # → "a/b"
path.clean("/../x") # → "/x"
path.rel("a/b/c", "a") # → "b/c"
path.rel("a", "a/b/c") # → "../.."
path.rel("/etc", "a") # → nil
path.is_abs("/etc") # → truePatterns
* and ? stay within one element, ** crosses any number of folders.
mzs
include path
path.match("*.mzs", "a.mzs") # → true
path.match("*.mzs", "src/a.mzs") # → false
path.match("**/*.mzs", "src/a.mzs") # → true
path.match("src/**/test_*.mzs", "src/test_a.mzs") # → true
path.match("[a-c]?.txt", "b1.txt") # → trueTo find files by pattern: io.walk + path.match, see io.