Path Functions¶
File path manipulation functions.
Summary¶
| Function | Signature | Description |
|---|---|---|
path_basename |
string -> string |
Get filename from path |
path_dirname |
string -> string |
Get directory from path |
path_ext |
string -> string |
Get file extension |
path_is_absolute |
string -> boolean |
Check if path is absolute |
path_is_relative |
string -> boolean |
Check if path is relative |
path_join |
string... -> string |
Join path segments |
path_stem |
string -> string |
Get filename without extension |
Functions¶
path_basename¶
Get filename from path
Signature: string -> string
Examples:
# Unix path
path_basename('/foo/bar.txt') -> "bar.txt"
# Directory path
path_basename('/foo/bar/') -> "bar"
# Just filename
path_basename('file.txt') -> "file.txt"
CLI Usage:
path_dirname¶
Get directory from path
Signature: string -> string
Examples:
# Unix path
path_dirname('/foo/bar.txt') -> "/foo"
# Nested path
path_dirname('/foo/bar/baz') -> "/foo/bar"
# No directory
path_dirname('file.txt') -> ""
CLI Usage:
path_ext¶
Get file extension
Signature: string -> string
Examples:
# Text file
path_ext('/foo/bar.txt') -> "txt"
# Image file
path_ext('image.png') -> "png"
# No extension
path_ext('noext') -> ""
CLI Usage:
path_is_absolute¶
Check if path is absolute
Signature: string -> boolean
Examples:
# Absolute path
path_is_absolute('/foo/bar') -> true
# Relative path
path_is_absolute('foo/bar') -> false
# Filename only
path_is_absolute('file.txt') -> false
CLI Usage:
path_is_relative¶
Check if path is relative
Signature: string -> boolean
Examples:
# Relative path
path_is_relative('foo/bar') -> true
# Filename only
path_is_relative('file.txt') -> true
# Absolute path
path_is_relative('/foo/bar') -> false
CLI Usage:
path_join¶
Join path segments
Signature: string... -> string
Examples:
# Multiple segments
path_join('/foo', 'bar', 'baz') -> "/foo/bar/baz"
# Full path
path_join('/home', 'user', 'file.txt') -> "/home/user/file.txt"
# Relative path
path_join('a', 'b') -> "a/b"
CLI Usage:
path_stem¶
Get filename without extension
Signature: string -> string
Examples:
# Simple file
path_stem('file.txt') -> "file"
# Double extension
path_stem('/foo/bar.tar.gz') -> "bar.tar"
# No extension
path_stem('noext') -> "noext"
CLI Usage: