Lets say my structure is like this
/-- am here
/one/some/dir
/two
/three/has/many/leaves
/hello/world
and say /one/some/dir contains a big file, 500mb, and /three/has/many/leaves contains a 400mb file in each folder.
I want to generate the size for each directory, to have this output
/ - in total for all
/one/some/dir 500mb
/two 0
/three/has/many/leaved - 400mb
/three/has/many 800
/three/has/ 800+someotherbigfilehere
How would I go about this?
Have a look at
os.walk. Specifically, the documentation has an example to find the size of a directory:This should be easy enough to modify for your purposes.
Here’s an untested version in response to your comment: