How to delete only contents from folder? contents might include folders and files
4 次查看(过去 30 天)
显示 更早的评论
Hi
How to delete only contents from folder? contents might include folders and files
Best Vahid
1 个评论
Azzi Abdelmalek
2015-7-28
How to delete only contents from folder? Is there anything else then contents?
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!