Syntax
fn=filepartl(fname,[fmt])
Input Parameter
fname : | | original file name |
fmt : | | 'e' if extension should be added; 'p' if path should be added |
Output Parameter
Examples
filepartl('/Users/timlueth/Desktop/Book.pdf')
filepartl('/Users/timlueth/Desktop/Book.pdf','p')
filepartl('/Users/timlueth/Desktop/Book.pdf','pe')
filepartl('/Users/timlueth/Desktop/Book.pdf','e')
Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, filepartl
, is designed to compile a filename from its parts, similar to the built-in fileparts
function in MATLAB. It is part of the SolidGeometry library and was introduced in version 5.0.
Input Parameters
- fname: The original file name, including its path and extension.
- fmt: An optional parameter that specifies which parts of the file name should be included in the output. It can be:
- 'e' - to include the file extension.
- 'p' - to include the file path.
Output
- fn: The compiled file name based on the specified format.
Algorithm Steps
- The function begins by retrieving the format parameter
fmt
using the helper function getfuncparams
. If fmt
is not provided, it defaults to 'n'.
- The
fileparts
function is used to split the input fname
into three components:
fp
- the file path.
fn
- the file name without the extension.
fe
- the file extension.
- The function checks if the format
fmt
contains 'p' (case-insensitive). If it does, the file path fp
is concatenated with the file name fn
, separated by the system's file separator filesep
.
- The function checks if the format
fmt
contains 'e' (case-insensitive). If it does, the file extension fe
is appended to the file name fn
.
- The final compiled file name
fn
is returned as the output.
Example Usage
filepartl('/Users/timlueth/Desktop/Book.pdf')
- Returns 'Book' (default behavior without 'p' or 'e').
filepartl('/Users/timlueth/Desktop/Book.pdf','p')
- Returns '/Users/timlueth/Desktop/Book'.
filepartl('/Users/timlueth/Desktop/Book.pdf','pe')
- Returns '/Users/timlueth/Desktop/Book.pdf'.
filepartl('/Users/timlueth/Desktop/Book.pdf','e')
- Returns 'Book.pdf'.
Algorithm explaination created using ChatGPT on 2025-08-18 23:24. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21