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
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
- fname: The file name to be incremented.
- step: The step size for incrementing the file name. Default is +1.
- fchk: A boolean to check if the file or folder exists. Default is true.
- srch: A boolean to attempt increasing the file name if it doesn't exist. Default is false.
- dchn: A boolean to also increase file names in folder names. Default is true.
Output Results
- fni: The incremented file name.
- nstr: The new string after incrementing.
Algorithm Steps
- Retrieve optional parameters using
getfuncparams
function with default values.
- If
fname
is empty, return empty fni
and nstr
.
- Use
fileparts
to split fname
into path, name, and extension.
- Call
strcounter
to increment the file name by step
.
- If
dchn
is true, replace occurrences of the old string in the path with the new string.
- Reconstruct the full file name with the new path, incremented name, and original extension.
- If
fchk
is true, check if the file or folder exists. If not, set fni
to empty.
- 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