Skip to main content

1E 8.1 (on-premises)

DIRECTORYFROMPATH

Function

DIRECTORYFROMPATH

Action

Takes a path as a string and returns the parent directory of the basename.

Parameters

(string) Path of file or directory.

Return values

(string) Path.

Example

@path = "c:\\tmp\\things\\files\\file.txt";
// returns c:\tmp\things\files
@path = SELECT DIRECTORYFROMPATH(Value) AS Value FROM @path;
// returns c:\tmp\things
@path = SELECT DIRECTORYFROMPATH(Value) AS Value FROM @path;
// returns c:\tmp
@path = SELECT DIRECTORYFROMPATH(Value) AS Value FROM @path;
// This example returns "/var/log/product2"
SELECT DIRECTORYFROMPATH("/var/log/product2/info.log");

Notes

The function is not file system aware; it does not check to see if the path or file exists.

The function is OS aware; it assumes the directory separator is \ on Windows and / on other OS.

Like the UNIX dirname command, it returns everything before the last path separator character in the string supplied.