How to delete only contents from folder? contents might include folders and files

4 ビュー (過去 30 日間)
Vahid Ghorbanian
Vahid Ghorbanian 2015 年 7 月 28 日
回答済み: Walter Roberson 2015 年 7 月 28 日
Hi
How to delete only contents from folder? contents might include folders and files
Best Vahid
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 28 日
How to delete only contents from folder? Is there anything else then contents?

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 7 月 28 日
whichfolder = 'MyFolderName';
dinfo = dir(fullfile(whichfolder,'*.*'));
dinfo(dinfo.isdir) = []; %remove the directories from consideration
for K = 1 : length(dinfo)
thisfile = fullfile(whichfolder, dinfo(K).name);
delete(thisfile);
end

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by