Wednesday, August 5, 2009

fileparts

Return filename parts

Syntax

  • [pathstr,name,ext,versn] = fileparts('filename')

Description

[pathstr,name,ext,versn] = fileparts('filename') returns the path, filename, extension, and version for the specified file. The returned ext field contains a dot (.) before the file extension.

The fileparts function is platform dependent.

You can reconstruct the file from the parts using

  • fullfile(pathstr,[name ext versn])

Examples

This example returns the parts of file to path, name, ext, and ver.

  • file = '\home\user4\matlab\classpath.txt';

    [pathstr,name,ext,versn] = fileparts(file)

    pathstr =
    \home\user4\matlab

    name =
    classpath

    ext =
    .txt

    versn =
    ''

No comments:

Post a Comment