How to delete this files..?

조회 수: 54 (최근 30일)
Lalit Patil
Lalit Patil 2013년 2월 21일
댓글: Renan Deuter 2021년 2월 3일
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
Jan
Jan 2013년 2월 21일
You can omit the square braces around the strings:
f=dir('*.txt')
delete(f{k})
This saves processing time.

댓글을 달려면 로그인하십시오.

답변 (2개)

Sean de Wolski
Sean de Wolski 2013년 2월 21일
Also make sure that the files aren't open in MATLAB or another program.
  댓글 수: 2
Lalit Patil
Lalit Patil 2013년 2월 23일
Yes those are open in MATLAB. So, i can close that and then can go ahead..
So, how to close this multiple all files.?
Sean de Wolski
Sean de Wolski 2013년 2월 25일
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
Thorsten 2013년 2월 21일
Ensure that you have the permission to delete the files.
  댓글 수: 1
Renan Deuter
Renan Deuter 2021년 2월 3일
Where can I see and change this?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by