filepartl

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 5.0, Creation date: 2021-02-19, Last change: 2025-09-15

compiles a filename from parts similar to fileparts



See Also:

Example Illustration

 missing image of filepartl(fname,fmt)

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

fn: filename

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

Output

Algorithm Steps

  1. The function begins by retrieving the format parameter fmt using the helper function getfuncparams. If fmt is not provided, it defaults to 'n'.
  2. 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.
  3. 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.
  4. 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.
  5. The final compiled file name fn is returned as the output.

Example Usage

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