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

4 visualizaciones (últimos 30 días)
Hi
How to delete only contents from folder? contents might include folders and files
Best Vahid

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Jul. de 2015
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

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by