Next Available Filename

Return the next unused filename, incrementing an integer as required.

Download
Download

You are now following this Submission

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Cite As

Stephen23 (2026). Next Available Filename (https://ch.mathworks.com/matlabcentral/fileexchange/64108-next-available-filename), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
4.0.8

* Output FPA is joined, not array
* Add test function and class
* Fix bug when empty BASENAME
* Improve code comments

Download
4.0.7

* Improve INTMAX handling

Download
4.0.6

* Improve documentation.

Download
4.0.5

* Improve documentation.

Download
4.0.4

* Improve documentation
* Correct bug in 3rd output

Download
4.0.3

* Input checking and error message improvements.
* Documentation improvements.

Download
4.0.2

* Documentation improvements.

Download
4.0.1

* Documentation improvements.

Download
4.0.0

* Add syntax 1: filename with integer in angle brackets.
* Documentation improvements.

Download
3.1.0

* Return name with same class as first input.

Download
3.0.2

* 4th input accepts numeric or logical.
* Improve documentation.

Download
3.0.1

Simplify string handling.

Download
3.0.0

* Accepts string scalar or char vector inputs.
* Add error IDs.

Download
2.0.0

* Separate file extension input (allows for no-ext names and folders with periods).

Download
1.3.1

* Simplify documentation examples.

Download
1.3.0

* Optional third input selects to return name only or same path as input name.
* Use UINT64 for simpler integer handling.

Download
1.2.1

* Improve efficiency.

Download
1.2.0

* Handle single matched subfolder.

Download
1.1.0

* Add check for no matching files.

Download
1.0.0

* Update HTML docs.

Download