treesize — Get Sizes of all Files and Folders in a Tree

New: as of June 2017, treesize includes a minor update to skip symlinks on platforms that support them, so the size tally isn't inflated artificially. Symlinks are rare on Windows, but not on Mac OS X. See the script's docstring for details.

This modest Python 3.X program generates a report giving the total space taken by each folder and file in a directory tree, grouped by type and ordered by size. This includes all the subfolders nested in the tree; each folder's size is computed from its contents recursively.

This script's main goal is to help locate candidates for removal when reclaiming disk space; navigating with file explorer GUIs tends to be tedious (or unusable) in this role. Its report file also provides a snapshot of the contents of your folders or drives. While there are tools to do similar work on some platforms, treesize is a portable option that works everywhere that Python does. See the main script's docstring and other items below for usage details.

Code and docs:

Examples:

Download/view all:

This program was last changed June 11, 2017.

For more code examples, see the programs page.


[Python Logo] Home Books Programs Blog Python Author Training Email Search ©M.Lutz