How to delete this files..?
Afficher commentaires plus anciens
f=dir(['*.txt'])
f={f.name}
n=find(strcmp(f,'Data.txt'));
f{n}=[]
for k=1:numel(f);
delete([f{k}])
end
When i execute this program, most of the text files are deleted. But some are not and gives notice like as follow :
Warning: File not found or permission denied
Is there any way to overcome this..? Even i want to delete it..
1 commentaire
Jan
le 21 Fév 2013
You can omit the square braces around the strings:
f=dir('*.txt')
delete(f{k})
This saves processing time.
Réponses (2)
Sean de Wolski
le 21 Fév 2013
4 votes
Also make sure that the files aren't open in MATLAB or another program.
2 commentaires
Lalit Patil
le 23 Fév 2013
Sean de Wolski
le 25 Fév 2013
If the files are opened, i.e. by MATLAB you can either:
- fclose('all');
- Close and restart ML
If they're open in the editor, you can close the Edtior Window, or run this shortcut:
function CloseNoPrompt
%Close all editor windows without prompting
%Active Editor;
hEditor = matlab.desktop.editor.getActive;
%Close all files.
while ~isempty(hEditor);
closeNoPrompt(hEditor);
hEditor = matlab.desktop.editor.getActive;
end
Thorsten
le 21 Fév 2013
0 votes
Ensure that you have the permission to delete the files.
1 commentaire
Renan Deuter
le 3 Fév 2021
Where can I see and change this?
Catégories
En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!