필터 지우기
필터 지우기

Deleting folders with specific name

조회 수: 10 (최근 30일)
roozbeh yousefnejad
roozbeh yousefnejad 2018년 6월 4일
댓글: Jan 2018년 6월 5일
Hi I have one main folder which is named Newfolder.
C:\Users\sesa498313\Desktop\Newfolder
in this Newfolder there are many folders with different name such as F21802010055, F21802010058, etc. In some of these sub-folders there is a folder name FTC, and I want to delete all these folder at the first step. Can you please advise how I can do that?
Thanks

답변 (1개)

Jan
Jan 2018년 6월 4일
편집: Jan 2018년 6월 4일
Base = 'C:\Users\sesa498313\Desktop\Newfolder';
List = dir(fullfile(Base, '**', 'FTC'));
List = List([List.isdir]); % Folders only
for k = 1:numel(List) % [EDITED, typo: list -> List]
[status,msg] = rmdir(fullfile(List(k).folder, List(k).name));
is status ~= 1
fprintf(2, '%s\n', msg);
end
end
  댓글 수: 7
roozbeh yousefnejad
roozbeh yousefnejad 2018년 6월 4일
the version I am using is 2017b
Jan
Jan 2018년 6월 5일
Then dir understands the operation. In this case the message means, that the folder C:\Users\sesa498313\Desktop\del does not contain subfolders, which are called 'FTC'. Are you sure that you have such folders?

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

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by