Discussion:
directory size?
(too old to reply)
T
2020-05-15 19:00:18 UTC
Permalink
Hi All,

Is there a way to get your directory/sub-directory size from
straight CMD without power shell?


powershell -noprofile -command "ls -r D:\drivers | measure -s Length"

Count : 162
Average :
Sum : 2557511012
Maximum :
Minimum :
Property : Length

Is three a API call for this?

Many thanks,
-T
R.Wieser
2020-05-15 20:41:49 UTC
Permalink
T,
Post by T
Is three a API call for this?
Not that I know of.

What you can do however is to use "FindFirstFile" and its two sibblings to
iterate thru all files in a folder, and than add their sizes together as
well as counting them.

I'm not sure how the above responds to "reparse points" and hardlinks
though.

Also, iterating thru a folder will return /all/ entries - files as well as
subfolders (and possibly others) - , but not "diving into" the subfolders by
itself. If you want that (and looking at the "-r" you do) you need to do
that yourself. Suggestion: look up "recursion".

Regards,
Rudy Wieser
T
2020-05-15 20:44:18 UTC
Permalink
Post by R.Wieser
T,
Post by T
Is three a API call for this?
Not that I know of.
What you can do however is to use "FindFirstFile" and its two sibblings to
iterate thru all files in a folder, and than add their sizes together as
well as counting them.
I'm not sure how the above responds to "reparse points" and hardlinks
though.
Also, iterating thru a folder will return /all/ entries - files as well as
subfolders (and possibly others) - , but not "diving into" the subfolders by
itself. If you want that (and looking at the "-r" you do) you need to do
that yourself. Suggestion: look up "recursion".
Regards,
Rudy Wieser
Hi Rudy,

I will be using Raku on these systems and Raku's zef command
required GIT. Git comes with a bunch of Linux functions
such as `du` and `df`. I will do a external call to them.

Thank you for the help!

-T
R.Wieser
2020-05-16 06:55:08 UTC
Permalink
T,
Git comes with a bunch of Linux functions such as `du` and `df`. I will
do a external call to them.
That would certainly be the Linux way to do it. :-)
Thank you for the help!
You're welcome.

Regards,
Rudy Wieser

Loading...