MATLAB fileparts function

Share:

Description

Return filename parts.

Usage

1
fileparts(pathname)

Arguments

pathname

character string representing pathname to be parsed

Details

Determines the path, filename, extension, and version for the specified file. The returned ext contains a dot (.) before the file extension. The returned versn is always an empty string as the field is provided for compatibility with its namesake's results.

Value

Returns a list with components:

pathstr

character string representing directory path

name

character string representing base of file name

ext

character string representing file extension

versn

character string representing version. Unused

Note

Returns same insane results as does its namesake when handling relative directories, UNIX hidden files, and tilde expansion. Hidden files are returned with name containing a zero length vector and ext containing the actual name. For best results, use this routine to process files, not directories.

Author(s)

P. Roebuck proebuck@mdanderson.org

See Also

fullfile

Examples

1
2
3
## Rename dot-txt file as dot-csv
ans <- fileparts("/home/luser/foo.txt")
fullfile(ans$pathstr, paste(ans$name, "csv", sep="."))   # /home/luser/foo.csv

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.