Folder Size
Vino.B via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 21 07:39:52 PDT 2017
On Monday, 21 August 2017 at 08:57:52 UTC, Aravinda VK wrote:
> On Saturday, 19 August 2017 at 14:19:39 UTC, Vino.B wrote:
>> [...]
>
> Keep a variable to add the sizes of subdirs
>
> auto dFiles = dirEntries(i, SpanMode.shallow).filter!(a =>
> a.isDir && !globMatch(a.baseName, "*DND*")).array;
> ulong subdirTotal = 0;
> foreach (d; dFiles)
> {
> subdirTotal = 0;
> auto SdFiles = dirEntries(d, SpanMode.depth).array;
> foreach(f; SdFiles) {
> subdirTotal += f.size;
> }
> writeln(d, "\t", subdirTotal);
> }
>
> --
> Aravinda
> http://aravindavk.in
Hi Aravinda,
Thank you for the idea, but i have to tweek my code toas below
to get the required output and now I am able to get the required
output
auto dFiles = dirEntries(i, SpanMode.shallow).filter!(a =>
a.isDir && !globMatch(a.baseName, "*DND*")).array;
foreach (d; dFiles)
{
auto SdFiles = dirEntries(d, SpanMode.depth).array;
//auto entry = SdFiles.front;
foreach (f; SdFiles)
{
subdirTotal += f.size;
}
ulong subdirTotalGB = (subdirTotal/1000/1000);
writefln("%-63s %s %s", d, subdirTotalGB, " MB");
subdirTotal = 0;
}
From,
Vino.B
More information about the Digitalmars-d-learn
mailing list