how can i calculate total size of a folder?

26 visualizaciones (últimos 30 días)
Pradeep Gowda
Pradeep Gowda el 10 de Mayo de 2015
Respondida: Avnet el 3 de Abr. de 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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Mayo de 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.

Más respuestas (1)

Avnet
Avnet el 3 de Abr. de 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

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by