Delete files with specific sizes

조회 수: 5 (최근 30일)
Oktavian Jason
Oktavian Jason 2020년 2월 14일
댓글: Bhaskar R 2020년 2월 15일
Hello everyone,
I want to ask a question.
I have a directory of flight data files and I want to delete some files that have less size than, for example 500 kb.
Is there any way to do it in loop?
Thanks

채택된 답변

Bhaskar R
Bhaskar R 2020년 2월 14일
Get the directory files
files = dir('your directory');
Apply loop and delete with your condition
for ii = 1:length(files)
if files(ii).bytes<500000 % 500kb
delete(fullfile(files(ii).folder, files(ii).name)
end
end
  댓글 수: 5
Oktavian Jason
Oktavian Jason 2020년 2월 14일
actually i'm a bit confused how to use these. (i'm new to matlab).
can you please give me the example?
let's say my folder is "Project" in D drive, and the folder has about 600 files.
Bhaskar R
Bhaskar R 2020년 2월 15일
You can learn/refer MATLAB fundamentals to apply solution to your problem. MATLAB provides very rich documentation clearly.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by