how can i calculate total size of a folder?

23 vues (au cours des 30 derniers jours)
Pradeep Gowda
Pradeep Gowda le 10 Mai 2015
Commenté : SOMNATH BAKSI le 10 Déc 2024
i'm reading a folder of images , now i wanna display its total size in my GUI. how can i get total size of the folder that i access?
  1 commentaire
SOMNATH BAKSI
SOMNATH BAKSI le 10 Déc 2024
SubFolder = dir(fullfile(app.datasetFolder,'*'));
folderSize = setdiff({SubFolder([SubFolder.isdir]).name},{'.','..'});
if(size(folderSize,2) == 0)
errordlg('Folder does not have any data');
else
disp(folderSize)
end

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 10 Mai 2015
Use this Recursive Directory File Exchange contribution, and add up all the bytes fields.
Note: the meaning if bytes on a directory entry would depend upon your operating system.

Plus de réponses (1)

Tria Technologies
Tria Technologies le 3 Avr 2024
This does the trick:
D = dir('**/*.mat'); % descends current folder and its sub-folders
total_bytes = 0;
for ii = 1:length(D)
total_bytes = total_bytes + D(ii).bytes;
end

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by