fs_sizes_stats.py is a Python utility that analyzes file size distributions across a directory tree. It scans a specified directory (or the current directory by default), collects file size information, and provides statistical summaries to help understand storage usage patterns.
- Fast recursive directory scanning with error handling for inaccessible files/directories
- Categorizes files into configurable size buckets (from <1KB to ≥1GB)
- Provides comprehensive statistics including:
- Total file count
- Total storage usage
- Average file size
- Distribution of files across size buckets
- Percentage of files in each size category
- Total size of files in each bucket
- Percentage of total storage used by each size category
python fs_sizes_stats.py [directory_path]If no directory path is provided, the script will analyze the current working directory.
Time taken: 23.8087 seconds
Total files: 1417378
Total size: 1.67TB
Average file size: 1.24MB
Size distribution:
Size Range | Files | % Files | Size | % Size
------------------------------------------------------------
<1KB | 395728 | 27.92% | 173.59MB | 0.01%
1KB–10KB | 668171 | 47.14% | 2.31GB | 0.14%
10KB–100KB | 294747 | 20.80% | 8.10GB | 0.47%
100KB–1MB | 39034 | 2.75% | 10.79GB | 0.63%
1MB–10MB | 11070 | 0.78% | 37.73GB | 2.21%
10MB–100MB | 4722 | 0.33% | 206.72GB | 12.08%
100MB–1GB | 3768 | 0.27% | 855.78GB | 50.01%
≥1GB | 138 | 0.01% | 589.54GB | 34.45%