question to continue the code
Ältere Kommentare anzeigen
I would like to create a code that creates a folder, verifies if it already exists and if it occurs asks the user if continue or not.
If the folder already exists, two options should be available:
- overwrite the folder (delete it and remake)
- terminate the code
My code is:
name='Folder';
loadcase='11';
if ~exist([name,loadcase], 'dir') % create saving folder
mkdir([name,loadcase]);
else
prompt=('The folder already exists. Do you want to overwrite the analysis?');
risp=input(prompt,'s');
if risp=='Y'
rmdir([name,loadcase]);
mkdir([name,loadcase]);
else
finish
end
end
3 Kommentare
darova
am 25 Feb. 2020
The code works. What is the question?
Walter Roberson
am 25 Feb. 2020
Probably what to put in in place of finish
If you were to put this into a function then return from the function.
Gaetano Pavone
am 25 Feb. 2020
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu File Operations finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!