filenameinc

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.9, Creation date: 2020-03-30, Last change: 2025-09-14

increases a file name and check it's existance by option



See Also: strcounter

Example Illustration

 missing image of filenameinc(fname,step,fchk,srch,dchn)

Syntax

fni=filenameinc(fname,[step,fchk,srch,dchn])

Input Parameter

fname: file name
step: step size; default is +1
fchk: check if file or folder; default is true
srch: default is false; try to increase the file name
dchn: increase also all file names in folder names; default is true;

Output Parameter

fni:

Examples


filenameinc('/Volumes/LUETH-WIN/Video_Lectures/AIM_02/AIM_LEC_02_SLIDE_05/AIM_LEC_02_SLIDE_05 INCL SOUND.avi')




Copyright 2020-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 algorithm is designed to increment a file name and optionally check its existence. It is part of the SolidGeometry library and was introduced in version 4.9. The function is named filenameinc and it takes a file name as input, along with optional parameters to control its behavior.

Input Parameters

Output Results

Algorithm Steps

  1. Retrieve optional parameters using getfuncparams function with default values.
  2. If fname is empty, return empty fni and nstr.
  3. Use fileparts to split fname into path, name, and extension.
  4. Call strcounter to increment the file name by step.
  5. If dchn is true, replace occurrences of the old string in the path with the new string.
  6. Reconstruct the full file name with the new path, incremented name, and original extension.
  7. If fchk is true, check if the file or folder exists. If not, set fni to empty.
  8. If srch is true and fni is empty, recursively call filenameinc with increased step size until a valid file name is found or a limit is reached.
Algorithm explaination created using ChatGPT on 2025-08-19 01:36. (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