Skip to content

Reports the file sizes of folders and/or files in a directory

Notifications You must be signed in to change notification settings

MTwem/DirectorySizes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

DirectorySizes

Small utility to list sizes of folders under a specified directory.

Features

  • Recursively computes total size (bytes) of files under each directory
  • Options for human-readable output, sorting, max depth and minimum size filter
  • Works on Linux/WSL; includes notes for OneDrive and Windows path handling

Requirements

  • Python 3.8+

Usage

Basic:

python3 dir_sizes.py /path/to/dir

Human-readable, limit depth to immediate children:

python3 dir_sizes.py /path/to/dir --human --max-depth 1

Sort by name and show only folders >= 1 MB:

python3 dir_sizes.py /path/to/dir --sort=name --min-size=1048576

WSL / Windows paths

If you run this from WSL and have a Windows path like C:\Users\You\OneDrive\Pictures:

  • use the WSL-mounted path /mnt/c/Users/You/OneDrive/Pictures
  • or convert automatically with wslpath:
python3 dir_sizes.py "$(wslpath 'C:\\Users\\You\\OneDrive\\Pictures')" --human

Note about OneDrive and Files On-Demand

  • If OneDrive uses Files On-Demand (placeholder files), some files may not be physically present until downloaded in Windows. Mark important files as "Always keep on this device" in Windows Explorer before inspecting from WSL.

Performance note

  • The script computes sizes by walking directories and summing file sizes. For very large trees it may repeat traversals and be slow. If you need faster/bulk scans, consider a single-pass aggregator or using tools like du -b / ncdu for interactive inspection.

Contributing

  • Open an issue or submit a pull request to improve path handling, performance, or add tests.

License

  • No license is included by default. Add a LICENSE file to the repository if you want to make the project public under a specific license.

About

Reports the file sizes of folders and/or files in a directory

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages