File Exchange

image thumbnail

Avoid file overwrite

version 1.0.0.0 (3.02 KB) by Simon Musall
Function to check if a file name already exists and create a new unique name by enumeration.

6 Downloads

Updated 12 Nov 2016

View License

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

Function to check if a given file already exists. If a matching file is found, it creates a new filename that can be used to avoid overwriting. New file names are created by appending a sequence like '_001' to the file name. If earlier numerations exist already, the next unused number is used to allow saving file sequences, based on the same initial name. The starting value of the enumeration and the number of used digits are adjustable if needed.

Cite As

Simon Musall (2021). Avoid file overwrite (https://www.mathworks.com/matlabcentral/fileexchange/60179-avoid-file-overwrite), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

Chang hsiung

Shaul Shvimmer

Works great, thank you.

Mikhail Monakhov

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!