FileTools
SplitPath
split filepath into components
JoinPath
join components into filepath
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
SplitPath(filepath, opts)
JoinPath(components, opts)
filepath
-
string; filepath, relative or absolute
components
list of strings; components of a filepath, relative or absolute
opts
options as described below
base=one of bindir, datadir, homedir, mapledir, tempdir, toolboxdir, worksheetdir.
The base option specifies a base directory. The parameter components will be interpreted as a relative path under this directory. For the meaning of worksheetdir see interface; for any other of these symbols, see kernelopts. This option is only supported for JoinPath.
platform=one of "unix", "windows", or auto
The platform option specifies the operating system conventions to use when splitting or joining paths. The default value, auto, uses the conventions of the current system.
The SplitPath command splits a filepath into a list of its path components. The JoinPath(components) command joins a list of path components into a filepath appropriate for the host operating system.
SplitPath("SomeDir/SomeFile") returns ["SomeDir", "SomeFile"] and JoinPath(["SomeDir", "SomeFile"]) returns either "SomeDir/SomeFile" (on macOS and UNIX) or "SomeDir\SomeFile" (on Windows).
On Windows, SplitPath(filepath) handles paths corresponding to file shares specially, keeping the server and share name together. For example, SplitPath("\\SERVER\Share\SomeDir") returns ["\\SERVER\Share", "Somedir"].
SplitPath interprets either a slash (/) or backslash (\) character as a delimiter. JoinPath(components) joins its components together using a delimiter specific to the host operating system.
Neither command checks that the input corresponds to an existing file on disk or performs any disk input/output.
FileTools:-SplitPath( "C:\\Program Files\\Microsoft Office" );
C:,Program Files,Microsoft Office
FileTools:-JoinPath( ["C:", "Program Files", "Microsoft Office"], platform = "windows" );
C:\Program Files\Microsoft Office
FileTools:-JoinPath( ["DirectoryA", "Subdirectory", "MyFile.txt"] );
DirectoryA/Subdirectory/MyFile.txt
The FileTools[SplitPath] and FileTools[JoinPath] commands were introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
See Also
FileTools[Filename]
FileTools[ParentDirectory]
Download Help Document