help pathutil

Title

pathutil -- File path manipulation

Syntax

Split path

pathutil split
["]path["]

Cut path into pieces

pathutil pieces
["]path["]

Join path

pathutil join
["]path1["]
["]path2["]

Path to directory

pathutil {to|of}
[directory]

Confirm directory

pathutil confirm [ new | url | absolute ]
"path"

Description

pathutil is a bundle of utility commands for file
path manipulation. The commands are inteded for use by
programmers. All commands are implemented in terms of
Mata's path*() functions.

pathutil split splits path into directory, filename, and
extension/suffix. Elements are returned in s(). If path has no
directory, filename or file extension/suffix, the respective elements
are omitted from s().

pathutil pieces cuts path into pieces and returns the elements
s().

pathutil join forms path1path2 and returns it in
s().

pathutil {to|of} is a clone of pathof
(Barker 2014), conceptually. It returns in s()
the current working directory up to the specifed directory or the
root of the current working directory, if directory is not specified.

pathutil confirm confirms that path is of the claimed type
(see confirm). Nothing is returned in s() and previous
contents in s() are preserved. This command is similar to
Blanchette's (2011) confirmdir.

Remarks

Earlier versions of pathutil were released under the simpler
name path; typing path instead of pathutil continues
to work until, some day, StataCorp decides to write their own path
command. Thus, I recommend changing old code and typing pathutil.

Example

. pathutil split "c:adopluspath.ado"

. sreturn list

. pathutil pieces "c:adopluspath.ado"

. sreturn list

. pathutil join "c:ado" "pluspath.ado"

. sreturn list

. pathutil confirm "c:ado"

Saved results

pathutil split saves in s()

Macros

s(filename) filename
(without extension/suffix)

s(extension) extension of filename
(same as s(suffix))

s(suffix) suffix of filename
(same as s(extension))

s(directory) directory

pathutil pieces saves in s()

Macros

s(pieces) number of pieces (0 if none)

s(piece#) elements of path (reverse order)

pathutil join saves in s()

Macros

s(path) path1path2

pathutil {to|of} saves in s()

Macros

s(path) (up to directory)

pathutil confirm saves nothing in s()

References

Barker, M. (2014). PATHOF: Stata module
to return the absolute path of any parent directory of the
current working directory. Statistical Software Components.

Blanchette, D. (2011). CONFIRMDIR:
Stata module to confirm if a directory exists.
Statistical Software Components.

Author

Daniel Klein

University of Kassel

klein.daniel.81@gmail.com

Also see

Online: pathjoin(), confirm,
_getfilename

if installed: confirmdir, pathof,
getfilename2, normalizepath, extractfilename