Revision: 39884
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 22, 2011 04:10 by silviud
Initial Code
def _total_size(source): total_size = os.path.getsize(source) for item in os.listdir(source): itempath = os.path.join(source, item) if os.path.isfile(itempath): total_size += os.path.getsize(itempath) elif os.path.isdir(itempath): total_size += self._total_size(itempath) return total_size
Initial URL
Initial Description
this will display the size of a directory as if you run du -sb dir
Initial Title
Python recursive get size of directory
Initial Tags
python, unix, linux
Initial Language
Python