Skip to content

Filepath Relative

Finds a relative path from a base path to a target path.

Inputs#

Port Description
Base Path
The base path to measure from.
Target Path
The target path to measure to.

Outputs#

Port Description
The relative path from basepath to targpath.

Addendum#

Operation#

Calculates a relative path from basepath to targpath. The relative path is the path that, when joined to basepath, leads to targpath.

An error is returned if targpath cannot be made relative to basepath (e.g., they are on different volumes on Windows) or if the computation fails.

Path Style Base Path Target Path Output
POSIX-style /a/b/c /a/b/c/d/e d/e
POSIX-style /a/b/c /a/b/d/e ../d/e
POSIX-style /a/b /c/d ../../c/d
Windows-style C:\a\b\c C:\a\b\c\d\e d\e
Windows-style C:\a\b\c C:\a\b\d\e ..\d\e
Windows-style C:\a\b D:\c\d (error)

ID: filepath-rel@v1